I don't know what's wrong with this:
function a()
game.ServerStorage.Gallardo:Clone(game.Workspace)
end
script.Parent.Parent.ClickDetector.MouseClick:connect(a)
I don't know what's wrong with this:
function a()
game.ServerStorage.Gallardo:Clone(game.Workspace)
end
script.Parent.Parent.ClickDetector.MouseClick:connect(a)
Assuming this is in a scriptand the parenting is correct..
I would usually give a better explanation, but really it's fairly basic.
The :Clone method has no parameters. So, you would have to make a variable then parent that variable to the workspace.
I also added in WaitForChild which waits for 'Gallardo' to be there. Just to be safe!
If the script is in a part and the ClickDetector is in that part, your parenting should be script.Parent.ClickDetector.MouseClick:connect(a) You can read more about Click Detectors here
I think you'd have the parenting done well though!
Cheers!
function a()
local clone = game.ServerStorage:WaitForChild("Gallardo"):Clone()
clone.Parent = workspace
end
script.Parent.Parent.ClickDetector.MouseClick:connect(a)
You don't have to make it a variable to clone an object. 'game.ServerStorage.Gallardo:Clone().Parent = workspace' is sufficient enough for a simple script. Unless if you want to do something with the clone besides parenting it.
I know! It's been proven that using variables is more efficient.(In other programming language I know). That's why I put that, silly! I think I know you don't need to make a variable.'
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
What does the output say?
The game thinks it's okay.
Read my answer!