I'm trying to make it so when you click a gui, a brick follows your mouse, and if you click again, the brick stops following your mouse. Why won't this work?
It's a localscript.
This is what I have:
player = game.Players.LocalPlayer
mouse = player:GetMouse()
function run()
script.Parent.TestValue.Value = true
local test = game.ReplicatedStorage.BuildItems.Test:clone()
test.Parent = game.Workspace
while true and script.Parent.TestValue.Value == true do
wait()
test.Position = Vector3.new(mouse.Hit.p.X,0.5,mouse.Hit.p.Z)
mouse.Button1Down:connect(function()
--script.Parent.TestValue.Value = false
break -- something is wrong with this
end)
end
end
script.Parent.MouseButton1Down:connect(function()
run()
end)
