So I have a basic script:
local plr = game.Players.LocalPlayer spawn(function() game:GetService('RunService').Stepped:Connect(function() local m = plr:GetMouse() print(m.Hit.p) workspace.SawBlade.Position = Vector3.new(m.Hit.p.X,m.Hit.p.Y,92) end) end)
It is suppose to take the SawBlade and put it on the mouse cursor then it is suppose to move the saw to Vector3.new(m.Hit.p.X,m.Hit.p.Y,92) but in doing so 92 isn't part of the mouses coordinate and when I move the mouse anywhere, the model lags behind it but the cursor doesn't, is there any math to fix it? I tried multiplying it by .001 even larger values and smaller but the model simply vanishes...
Help please..?
By lag I mean the everything is smooth but the model goes half the direction from the center to the mouse.
One thing you could do to fix lag a bit is to switch the mouse reference to the top of the script, another thing you can do is remove the print
part because your computer or server will slow down quite a bit if it must print once every tick.
Another thing @Elixcore mentioned was using mouse.Move
. mouse.Move
fires each time the player moves his or hers mouse cursor.
local plr = game.Players.LocalPlayer local m = plr:GetMouse() m.Move:connect(function() workspace.SawBlade.Position = Vector3.new(m.Hit.p.X,m.Hit.p.Y,92) end)
All of this together should optimize your code a bit and will most likely fix your problem entirely.
Oh yeah, alternative title since I'm just coming back to my old posts for fun. "How to create a plane for the mouse to move objects on without the vector world interference" or something like that.
I solved this by stealing code from devforum