Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Car doesn't work when cloned, but the original did?

I have a car spawn button, that when you click it, it spawns a car on you.

local model = game.Lighting.Carlel
local position = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position

function onClicked()
	local position = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position
    local a = model:clone()
    a.Parent = game.Workspace
	wait()
	a.MakeJoints()
    wait()
    a:MoveTo(position)
end
script.Parent.MouseButton1Click:connect(onClicked)

The original car that it copies from works, but the clones do not. If I stand on the seat of the clone, I don't get in, though when I stood on the original, I did.

1 comment

0

try parenting the car to the workspace last

1 answer

It's possible that this is not a problem in your code, maybe since the location of your model has changed and if there is a script that controls it outside of the model it may not be able to find the model. Sorry if that is badly phrased.

Another possibility is that some objects are not grouped within the car, so that when the car is cloned from lighting, it leaves behind some scripts or seats.

I hope this can solve your problem. If it does not, please comment so that I can seek further for ways to get rid of this glitch.

Merry Christmas! :D

Edit: check your output window if there is anything, and try using prints to check what parts of the code might be malfunctioning. You may want to consider rearranging some parts of your code to see if it fixes anything.

This discussion is preserved as it was. New answers, comments, and votes are closed.