Hello, I’ve been developing with others on a survival game project that involves airships that I helped specifically code in and am having issues regarding its movement. For whatever reason, despite it working as normally with 1 player, whenever there is more than 1 involved and nearby said airship, unexpected behavior occurs, i.e.; the ship tends to glitch out and attempt to move back to its original position where the owner of it placed it down (the game uses a building/structure placement system and airships use this system), and I have no idea why.
As far as I am aware, I have tested this with 2 clients myself in studio and the position of the ship when moved from its original position seems to be seen correctly by both clients, but again is only changed when the non-owner of it gets nearby/drives it instead. I am using a local script to implement mobile controls in the future with gui buttons and have a feeling this is the reason why, however am unsure on how to go about making it non-local.
Code in question:
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local seat = humanoid.SeatPart
local Einput = false
local Qinput = false
--------------------
-- VERSION 0.0.2A --
--------------------
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if seat ~= nil then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then -- descend
Einput = true
while Einput == true do
wait(0.1)
if seat.Parent.MainPart.BodyPosition.Position.Y <= -200 then
seat.Parent.MainPart.BodyPosition.Position = Vector3.new(0,-200,0)
if seat.Parent.MainPart.BodyPosition.Position.Y < -204 then
warn("Position of airship is abnormally low!")
end
else
seat.Parent.MainPart.BodyPosition.Position = seat.Parent.MainPart.BodyPosition.Position - Vector3.new(0,1,0)
end
end
end
if input.KeyCode == Enum.KeyCode.Q then -- ascend
Qinput = true
while Qinput == true do
wait(0.1)
if seat.Parent.MainPart.BodyPosition.Position.Y >= 400 then
seat.Parent.MainPart.BodyPosition.Position = Vector3.new(0,400,0)
if seat.Parent.MainPart.BodyPosition.Position.Y > 404 then
warn("Position of airship is abnormally high!")
end
else
seat.Parent.MainPart.BodyPosition.Position = seat.Parent.MainPart.BodyPosition.Position + Vector3.new(0,1,0)
end
end
end
end
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.E then
Einput = false
wait(0.1)
print("stop")
end
if input.KeyCode == Enum.KeyCode.Q then
Qinput = false
wait(0.1)
print("stop")
end
end)

Any help would be appreciated