When I click on something, I want a kart to appear. So, when I click it, it clones the kart from lighting (clones the kart from inside a model called Karts), and then appears in the game. It will do it the first time, but it doesn't clone it. There is also a script inside the kart seat so that when a player jumps out of it, it disappears. I don't know if that's messing up the teleport with the kart, but it shouldn't be. I don't know what line of code I should edit.
Clicked = script.Parent
BackUpButton = game.Debris.Button
BackUpTextThing = game.Debris.GenerateKart
function onMouseClick(Player)
game.Workspace.Button:remove()
game.Workspace.GenerateKart:remove()
wait(0.1)
m = game.Lighting.GoKarts:GetChildren()
mg = m[math.random(1,#m)]
wait(1)
mg.Parent = game.Debris
wait(1)
mg.Parent = game.Workspace
mg:makeJoints()
wait(10)
BackUpButton:clone().Parent = game.Workspace
BackUpTextThing:clone().Parent = game.Workspace
end
Clicked.MouseClick:connect(onMouseClick)
Here is the coding for the script inside the seat:
local car = script.Parent.Parent
script.Parent.ChildAdded:connect(function(o)
if o.Name == "SeatWeld" then
car.Parent = game.Workspace
end
end)
script.Parent.ChildRemoved:connect(function(o)
if o.Name == "SeatWeld" then
wait(1)
car:remove()
end
end)

1 comment
Well, the button is destroy and so is the script, but I have a backup button that is in ServerStorage.