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

Help with click detectors?

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)

3 comments

0

What does the output say?

0

The game thinks it's okay.

0

Read my answer!

1 answer

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)

2 comments

0

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.

0

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.