Seats not working when changing Vehicles parent

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**


** script.Parent.Text = “Speedboat - Owned!”**
** Speedboat.Name = “Speedboat”**
** SpawnBoat.Parent = workspace**
** wait(1)**


** print(“DONE”)**

** end**
end)
Speedboat.Value = true

I realize that making it a server script would work better, but i cant figure how to find leaderstats without game.Players.LocalPlayer

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.

I realize that i need to make it a server, but what i am struggling with, is getting a way to find leaderstats with out using LocalPlayer

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

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:Fire()
end)

in the server script

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
-- code to spawn in boat
end)

So, I will basically use 2 scripts to spawn a boat

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.

So, all i would do, is in the local script, define the user BUYING the boat, and in the server, they SPAWN the boat

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.

Thank you. You are a life saver. This hopefully will fix the seats not working

Problem. I am getting the error, Fire is not a member of remoteEvent?

oops use, FireServer instead
here is api

lol i just realized that :smiley:

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 :))