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

What's wrong with this ClickDetector script?

Asked by 10 years ago
x = script.Parent

function onMouseClick()
    noob = game.Lighting.Troll:Clone()
    noob.Name = "Troll"
    noob.Position = Vector3.new(-77.6, 2.4, 31.2)
    noob.Parent = Workspace
    noob:MakeJoints()
    x.Locked = true
    x.Transparency = 1
    x.CanCollide = false
    x.BrickColor = "Earth green"
    wait (3)
    x.Locked = false
    x.Transparency = 0
    x.CanCollide = true
    x.BrickColor = "Dark stone grey"
end

x.MouseClick:connect(onMouseClick)

It's supposed to make it so whenever I click the brick, the brick dissapears and a monster named "Troll" appears. Only it's not dissapearing and no Troll is appearing. My script is in Workspace>Part>ClickDetector>Script.

I guess you could say I'm being "Trolled"

Thanks in advance!

3 answers

Log in to vote
0
Answered by
ultrabug 306 Moderation Voter
10 years ago

You name x as "script.Parent", but if the script is in the ClickDetector it will not be able to change the properties you listed. You may also want to use a different method to move the "Troll", I think I heard somewhere that you have to use something else.

Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

You forgot to add ClickDetector in your connection line, and messed up on a few BrickColors.

x = script.Parent

function onMouseClick()
    noob = game.Lighting.Troll:Clone()
    noob.Name = "Troll"
    noob.Position = Vector3.new(-77.6, 2.4, 31.2)
    noob.Parent = game.Workspace
    noob:MakeJoints()
    x.Locked = true
    x.Transparency = 1
    x.CanCollide = false
    x.BrickColor = BrickColor.new("Earth green")
    wait (3)
    x.Locked = false
    x.Transparency = 0
    x.CanCollide = true
    x.BrickColor = BrickColor.new("Dark stone grey")
end

x.ClickDetector.MouseClick:connect(onMouseClick)

Log in to vote
-1
Answered by
Damo999 182
10 years ago

Well the first thing i noticed that was wrong about your script was your connection line it should be x.ClickDetector.MouseClick:connect(onMouseClick) i took out the Positioning portion of the code i could't get it to work but here is the working script.

x = script.Parent
detector = Instance.new("ClickDetector",x) --I prefer scripting in ClickDetector's

function onMouseClick()
    noob = game.Lighting.Troll:Clone()
    noob.Name = "Troll"
    noob.Parent = Workspace
    noob:MakeJoints()
    x.Locked = true
    x.Transparency = 1
    x.CanCollide = false
    x.BrickColor = "Earth green"
    wait (3)
    x.Locked = false
    x.Transparency = 0
    x.CanCollide = true
    x.BrickColor = "Dark stone grey"
end

x.ClickDetector.MouseClick:connect(onMouseClick) --fixed

Answer this question