Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there any math I can use that could align the mouse with the mesh part??

Asked by 5 years ago
Edited 5 years ago

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.

2
mouse.Move Elixcore 1337 — 5y
0
Should probably answer with that, Elixcore Ankur_007 290 — 5y
0
That isn't the question Ankur... That isn't the answer Elixcore greatneil80 2647 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

0
Won't work... I wasn't asking for efficiency, I was asking for math that would double to mouse cursor so like m.Hit.p.X*2 except that makes the entire model disappear greatneil80 2647 — 5y
0
Also the entire model glitches when this happens. it vanishes then comes back.. greatneil80 2647 — 5y
0
why 92 for Z value? JasonTheOwner 391 — 5y
0
its the distance from the camera to where the Z of the player is greatneil80 2647 — 5y
Ad
Log in to vote
0
Answered by 2 years ago

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

Answer this question