Hey, im doing a script for an arm to follow your cursor when an event is fired, but for some reason the m.Hit.Position.X/Z
isnt very accurate.
as you can see in the image its kinda offsetted a bit, i tried to add to the position (Vector3.new(m.Hit.Position.X,0,m.Hit.Position.Z) + Vector3.new(x,x,x)
), but it was so buggy, is there any fix to this?
Heres the code:
local plr = game.Players.LocalPlayer
local m = plr:GetMouse()
local runService = game:GetService("RunService")
local rs = game.ReplicatedStorage
local arm = rs.Assets.Arm
local remoteStart = rs:WaitForChild("Events"):WaitForChild("ArmFollowStart")
local remoteStop = rs:WaitForChild("Events"):WaitForChild("ArmFollowStop")
local following = false
local function Follow()
local armClone = arm:Clone()
armClone.Parent = workspace.Arm
local mPosX = m.Hit.Position.X
local mPosZ = m.Hit.Position.Z
while following do
mPosX = m.Hit.Position.X
mPosZ = m.Hit.Position.Z
local targetPosition = Vector3.new(mPosX, 0, mPosZ)
armClone:MoveTo(targetPosition)
task.wait()
end
end
remoteStart.OnClientEvent:Connect(function()
following = true
Follow()
end)
remoteStop.OnClientEvent:Connect(function()
following = false
workspace.Arm:ClearAllChildren()
end)
Ty!