Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local Players = game:GetService("Players")
- local player = Players.LocalPlayer
- local selectTemplate = ReplicatedStorage.select
- local selecting = false
- local select: Instance, mouseStart: Vector2, mouseEnd: Vector2
- UserInputService.InputBegan:Connect(function(input, processed)
- if processed then return end
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if not selecting then
- selecting = true
- select = ReplicatedStorage.select:Clone()
- select.Parent = player.PlayerGui.selection
- mouseStart = UserInputService:GetMouseLocation()
- select.Position = UDim2.fromOffset(mouseStart.X, mouseStart.Y)
- end
- end
- end)
- UserInputService.InputEnded:Connect(function(input, processed)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if selecting then
- selecting = false
- select:Destroy()
- end
- end
- end)
- RunService.Heartbeat:Connect(function(dt)
- if selecting then
- mouseEnd = UserInputService:GetMouseLocation()
- local x = (mouseStart.X - mouseEnd.X)
- local y = (mouseStart.Y - mouseEnd.Y)
- select.Size = -UDim2.fromOffset(x, y)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement