Hi, I’m making a rotating turret for my game, and I want the turret to be controllable from the players mouse, but my code doesnt seem the work:
game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(player, mouse)
while wait() do
gyro.CFrame = CFrame.new(part.Position ,Vector3.new(mouse.Hit.Position.X, part.Position.Y, mouse.Hit.Position.Z) )
end
end)
I’m getting this error: Hit is not a valid member of Vector3
I want the turret to follow the mouse position, I have done a lot of research, and all the posts I have found say to do mouse.Hit, but I’m getting said error, I’m not sure what to do.
You cannot pass the mouse to the server, because the limitation is due to possibly being non-replicated. Just send a Vector3 instead, passing Mouse.Hit.
Then the problem is in the code on the server. They’re supposed to be mouse.X and mouse.Z. You could rename the mouse argument into something like hitPosition.
There’s no error in the output, but the part behaves strange… it will only follow the mouse once in every 10 seconds and its wiggling constantly and looks glitchy, I don’t have any recording software, so I’m not sure how I can show you…
You need to be more clear on this.
This is what the script is supposed to look like (assuming mouse is a vector3):
game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(player, mouse)
while wait() do
gyro.CFrame = CFrame.new(part.Position ,Vector3.new(mouse.X, part.Position.Y, mouse.Z) )
end
end)
now if that works, then what does the localscript look like?