I am trying to clone() a car from ServerStorage and I was informed that I needed to call :MakeJoints() on the clone. I tried doing :Clone():MakeJoints() and that didn't work but it did if I named the model. The problem is that the car spawns every time someone respawns for their character, there will be a lot with the same name, and the car breaks without :MakeJoints(). I thought a good solution would be to name the model a name and have an increasing variable but I can't seem to get that to work.. Does anyone have a solution? Here is the code:
function onSpawned(plr) local kart = game.ServerStorage["Cart"]:Clone() kart:MakeJoints() kart.Parent = game.Workspace end function onChanged(prop,plr) if prop=="Character" then onSpawned(plr) end end function onAdded(plr) plr.Changed:connect(function(prop) onChanged(prop,plr) end) end game.Players.PlayerAdded:connect(onAdded)
If you want to spawn the car every time the player spawns then you should use the CharacterAdded
event instead of setting a listener function to the Changed
of the player.
function onSpawned () local kart = game.ServerStorage.Cart:Clone() kart.Parent = workspace kart:MakeJoints() end function onAdded (plr) plr.CharacterAdded:Connect(onSpawned) end game.Players.PlayerAdded:Connect(onAdded)