Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-3

Help with click detectors?

Asked by 9 years ago

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)
0
What does the output say? Senor_Chung 210 — 9y
0
The game thinks it's okay. SchonATL 15 — 9y
0
Read my answer! Thetacah 712 — 9y

1 answer

Log in to vote
-1
Answered by
Thetacah 712 Moderation Voter
9 years ago

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)
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. Redbullusa 1580 — 9y
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.' Thetacah 712 — 9y
Ad

Answer this question