Hello, I'm making a vehicle game and I have it so once a player joins the game it fires a remote event that spawns a car and teleports that player to the car but if someone joins after me they cannot see my car but instead see me flying around sitting in the air yet I see their car. Is it because they weren't there for when I fired the remote event to spawn my vehicle? or is it a different issue entirely? and can you guys give me any ideas on how to fix it?
Local script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("SpawnCar")
remoteEvent:FireServer()
Server Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("SpawnCar")
local spawns = workspace.Spawns:GetChildren()
local function onCreateCar(player)
local randomSpawn = spawns[math.random(#spawns)]
print(player.Name, "has requested a vehicle")
local car = ReplicatedStorage:WaitForChild("Car")
local carClone = car:Clone()
car.Parent = workspace
car:SetPrimaryPartCFrame(randomSpawn.CFrame)
game["Run Service"].Heartbeat:Wait()
player.Character.HumanoidRootPart.Position = car.VehicleSeat.Position
game["Run Service"].Heartbeat:Wait()
car.VehicleSeat:Sit(player.Character.Humanoid)
end
remoteEvent.OnServerEvent:Connect(onCreateCar)

1 comment
Thanks! I originally used Players.PlayAdded but it didnt work, assuming because I was using the car from ReplicatedStorage. I've yet to test this with other real players yet but it works in studio so hopefully its fixed!