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)

4 comments
How can i do that?
The best way I can think of right now would be to create the beam before they want to move it and then instead of an on and off remote, have a remote that only changes the position of the beam
but the off remote is to stop it
Fixed it thanks!