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

Can I have help on a part moving to the cursors postion?

Asked by 4 years ago
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local PosX,PosY,PosZ = Mouse.Hit.X,Mouse.Hit.Y,Mouse.Hit.Z
while wait (0.01) do
    game.Workspace.Part.Position = Vector3.new(PosX,PosY,PosZ)
end

I can not figure out everything seems right any ideas on whats wrong? (Is a local script in Player GUI)

1 answer

Log in to vote
0
Answered by
chasedig1 115
4 years ago
Edited 4 years ago

You are not updating the cursor position every hundredth of a second. Try this!

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

while wait (0.01) do
    local PosX,PosY,PosZ = Mouse.Hit.X,Mouse.Hit.Y,Mouse.Hit.Z
    game.Workspace.Part.Position = Vector3.new(PosX,PosY,PosZ)
end

If this helped, be sure to mark me as a solution. If not, please post why and I will get back to you as soon as possible. Thanks!

Ad

Answer this question