Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local frame = script.Parent
- local dragging = false
- -- turn on dragging when the mouse is pressed or the screen is touched
- frame.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- end
- end)
- -- turn off dragging when its released
- frame.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = false
- end
- end)
- -- helper function to draw one point at the given x,y position
- local function DrawAt(x, y)
- -- need the parent's position so we can subtract it from the child's
- local topLeft = frame.AbsolutePosition
- local point = Instance.new("Frame")
- point.BackgroundColor3 = Color3.fromRGB(0,0,0)
- point.Size = UDim2.fromOffset(5, 5)
- point.Position = UDim2.fromOffset(x - topLeft.X - 5, y - topLeft.Y - 5)
- point.Parent = frame
- end
- -- fired when the mouse or finger moves
- frame.InputChanged:Connect(function(input)
- if dragging and input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- DrawAt(input.Position.X, input.Position.Y)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment