Trying to make a script where you click a brick, it follows your mouse. But I don't understand how to find who clicked it
Normal script inside of a Click Detector inside of a brick that's in a model
script.Parent.MouseClick:connect(function(player) local Mouse = player.Mouse script.Parent.CFrame = CFrame.new(-0.02,Mouse.X,-0.05,Mouse.Y) end)
Thank you.
Your script have some mistakes
Instead of player.Mouse you need to use player:GetMouse()
To get mouse position you need to use mouse.Hit, and to get X,Y,Z use mouse.Hit.X and etc.
To make part always follow your mouse, you need to add infinite loop
To make mouse not detect your part as target, you need to put it in player's character.
With fixing all that mistakes, you will have script like that:
script.Parent.MouseClick:connect(function(player) local Mouse = player:GetMouse() script.Parent.Parent = player.Character while true do wait() script.Parent.Parent.CFrame = CFrame.new(Mouse.Hit.X,Mouse.Hit.Y,Mouse.Hit.Z) end end)