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)
I am not sure how to completely solve your problem as I am not familiar with Debris, but I suggest that instead of using Lighting, you should use ServerStorage. Also remove the Lighting tag, as it does not have anything to do with dynamic lighting or the properties of Lighting.
The Debris service is used to automatically remove parts from your workspace after a short time. Do not store parts or models in the Debris service if you intend to continue using them. Instead, store your items in the ServerStorage service...
Clicked = script.Parent BackUpButton = game.ServerStorage.Button BackUpTextThing = game.ServerStorage.GenerateKart function onMouseClick(Player) game.Workspace.Button:Destroy() game.Workspace.GenerateKart:Destroy() wait(0.1) m = game.ServerStorage.GoKarts:GetChildren() mg = gm[math.random(#m)] 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)