Hello Devforum, so I have a tiny plane and I want it to follow my mouse using BodyGyro by getting the mouse position from the client, firing it into the server and use this code: gyro.CFrame = CFrame.new(engine.Position,ms)
However, when I use this technique it doesn’t really follow it’s mouse and instead spins around as you can see in the video:
I have no idea how to fix this despite my research, I am sure the gyro has enough force to rotate the plane around. Here are my scripts:
Server
engine.Parent.Events.MousePosition.OnServerEvent:Connect(function(player,ms)
local gyro = engine:FindFirstChild("BodyGyro")
if gyro then
gyro.CFrame = CFrame.new(engine.Position,ms)
end
end)
Client
rs.Stepped:Connect(function()
if en == true then
local ms = mouse.Hit.Position
local s = speed
events.MousePosition:FireServer(ms)
events.UpdateSpeed:FireServer(s)
end
end)
All help and advise is appreciated, apologies in advance if I can’t get to you within the hour
Could this be because there is no ground below? I’m not going off much here but you could try having a large invisible plate follow the character from below.
engine.Parent.Events.MousePosition.OnServerEvent:Connect(function(player,ms)
local gyro = engine:FindFirstChild("BodyGyro")
if gyro then
gyro.CFrame = CFrame.lookAt(gyro.CFrame.Position, ms)
end
end)
Furthermore, I’d recommend looking at the Move event of the player’s mouse and bind the FireServer to that so it is not constantly firing server on each frame, but rather, when the mouse is moved (prevents it from firing the same position several times in a row). This may not align with your goals, but it would definitely be something to look at. Let me know if you have any further questions.