Help with Click Detector Function

I’m trying to make it where when I click on what I named “fuse”, what I named “cannonball” becomes visible by changing the transparency to 0.
image
I’m getting no error, it just wont work.

You need to make the 0 a number by removing the quotation marks.

Also

1 Transparency = invisible
0 Transparency = visible

2 Likes

That mistake really blew directly over my head, thanks for the help :smiley:

The only part I’m confused about now is why it still isn’t appearing… I did the corrected mistakes you listed, any other reasons this could be happening?
image
I changed it up a bit.
Still no errors in the output.

If you print cannonball what’s the output?

It says nothing in the output box. Is there a reason why?

Well that’ll mean that it’s not finding it. Also you said FindfirstChild it needs to be FindFirstChild (Pascal Case - Capital letter after every new word)

1 Like

At line 5, I don’t see the use of a FindFirstChild and by the way, you spelled it wrong : the second F needs to be a capital letter !

It looks like the Button1Down event doesn’t fire…

1 Like

Wait a minute I’m confused now are you clicking on a specific part, because the title says click detector

Yes, I’m clicking on a specific part called “fuse”, and its still not working for some reason.

So you need to have a click detector in that part. And add a script to handle the clicks.

Yes, there is a click detector in that part. Also, what do you mean by a script to handle the clicks? Isn’t that I screenshotted above?

The script would be something like

local clicker = script.Parent.ClickDetector

clicker.MouseClick:Connect(function()
    local cannonball = game.Workspace:FindFirstChild("cannonball")
    if cannonball then
        cannonball.Transparency = 0
        cannonball.Anchored = true
    end 
end)

Also this should be a Regular script in the fuse part

Ah your right, I could totally have used an if statement.

Also No that is not handled above because you are using the players mouse object and not the click detector

There is a small error in this script : it’s not clicker.Button1Click but clicker.MouseClick !

1 Like

Yeah sorry on mobile! I knew it wasn’t quite right just couldn’t think of the exact thing. Fixed it!

1 Like