First time posting, I hope this is the right category, at least it seemed most fitting in the list. Anyway.
I’m cloning a vehicle from a folder, and teleporting the player into the vehicle seat. This works fine 4/5 times, however sometimes, the VehicleSeat does not register the player has been put in the seat, and the vehicle won’t move. Gif showing issue:
Have you tried setting the Network Ownership to the driver? You can do this by getting the VehicleSeat’s Occupant (VehicleSeat.Occupant) and setting it by using:
local humanoid = VehicleSeat.Occupant
if humanoid then
local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
if player then
VehicleSeat:SetNetworkOwner(player)
end
It would be most useful if you can post the important sections (preferrably in the OP) of the local and server script so I can analyze what you have not done/ what may have gone wrong.
1 local Player = game.Players.LocalPlayer
2 local SpawnTank = game.ReplicatedStorage:WaitForChild("RemoteFunctions"):WaitForChild("SpawnTank")
3 local TankType = "Daimler_AC"
12 script.Parent.MouseButton1Click:connect(function()
14 local tankSpawned = SpawnTank:InvokeServer(TankType)
39 Player.Character.Humanoid.JumpPower = 0
40 end)
Server Script:
7 local Tanks = game.ReplicatedFirst:WaitForChild("Tanks")
8 local RequestTank = game.ReplicatedStorage:WaitForChild("RemoteFunctions"):WaitForChild("SpawnTank")
10 local function tankSpawnRequested(player, TankType)
12 local tank = Tanks.Daimler_AC:Clone()
13 tank.Parent = workspace
14 tank:MoveTo(workspace["MoveHere"..math.random(1,4)].Position)
15 tank.Name = "tank_"..player.Name
16 tank.TankParts.VehicleSeat:Sit(player.Character.HumanoidRootPart)
17 print(player.Name.." spawned a tank type: "..TankType)
18 tank.TankParts.VehicleSeat:SetNetworkOwner(player)
19 return tank
20 end
22 RequestTank.OnServerInvoke = tankSpawnRequested
Alright, I think I’ve fixed it. I got the idea to anchor the main Part and then unanchor it after a second, and now everything seems to be working. Thanks for helping, that’s what made me get the idea.
There is another bug though, where the model likes to glitch, but that’s for another topic.
I highly doubt this is the appropriate solution you’re looking for. This seems relatively hacky. A barebones file of the place you’re experiencing this issue in so we can analyse it would be very helpful.
Furthermore, whatever do you mean by “VehicleSeat does not register player”?