I have a boat in my game. It works just fine normally, but when I am changing the vehicles parent via Local Script, the seats no longer work. Here is the script.
local leaderstats = game.Players.LocalPlayer:WaitForChild(“leaderstats”) local BoatsOwned = game.Players.LocalPlayer:WaitForChild(“Boats Owned”) local Player = game.Players.LocalPlayer local Speedboat = Instance.new(“BoolValue”,BoatsOwned) local SpawnBoat = game.Lighting.Boats[“Speed Boat”]:Clone() Speedboat.Value = false script.Parent.MouseButton1Click:Connect(function(plr)
** if leaderstats.Gold.Value >= 0 then**
** Speedboat.Value = true**
** local Char = Player.Character**
** Char.HumanoidRootPart.CFrame = SpawnBoat.TPart.CFrame**
Before I start giving a solution. It looks like your script is a localscript, meaning that stuff won’t replicate. Try doing this:
Press play and spawn the boat in. In the home tab, you should see this “Current: Client”
Click it and you will switch to server. In the server, you may not be able to see the boat. This is because the boat is not replicated. In order to have it replicated, you will have to use RemoteEvents.
You should have the server spawn in the boat.
Client: Clicks button.
Client: Tells server button was clicked.
Server: [Usually you would have validation here to prevent hackers but that isn’t important in this context]
Server: Creates a boat
Server: (Handled by roblox) Replicates the boat to other clients.
How would you do this? Create a new RemoteEvent in ReplicatedStorage
in the localscript
One more thing, storing assets in Lighting is bad practice. ServerStorage exists to store stuff for the server. ReplicatedStorage exists to store stuff for the client.
Yes, two scripts will be needed to spawn a boat. One for the server, one for the client. However, each of them have different purposes. The client is just the GUI. The server should handle everything else.
It works! The seat and everything. You are a lifesaver, thank you! Even pressing current server the boat is still there. You just saved my game, thank you :))