Ok so ive got a script so when u hold down q it would make a beam depending on where your mouse cursor is but i have a problem it only moves the mouse once then stops and doesnt move again how can i fix this?
local on = false script.Remotes.On.OnServerEvent:Connect(function(plr,mouse) on = true local folder = Instance.new("Folder",workspace.Beams) folder.Name = plr.Name local endpart = Instance.new("Part",folder) endpart.Size = Vector3.new(0.99, 0.99, 0.99) endpart.Anchored = true local beam = script.Stuff.Beam:Clone() beam.Parent = plr.Character.LeftHand local att1 = Instance.new("Attachment",plr.Character.LeftHand) local att2 = Instance.new("Attachment",endpart) beam.Attachment0 = att1 beam.Attachment1 = att2 while on == true do local posx,posy,posz = mouse.X,mouse.Y,mouse.Z endpart.Position = Vector3.new(posx,posy,posz) wait() end end) script.Remotes.Off.OnServerEvent:Connect(function(plr) workspace.Beams[plr.Name]:Destroy() on = false plr.Character.LeftHand.Beam:Destroy() plr.Character.LeftHand.Attachment:Destroy() end)
The argument mouse that you pass through the event will not change unless you change it inside of the function. The changes you make to it on the client do not replicate over to the variable on the server; they are not connected in any way. So it is always the same value no matter what.
Basically meaning your local posx,posy,posz = mouse.X,mouse.Y,mouse.Z
will always result in the same thing.
You need to find a way to update the value that it should change its position to.