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

ClickDetector Jump Button isn't working, any help?

Asked by 6 years ago

I have a Part with a ClickDetector in it, and there is the following script inside of the ClickDetector:

local b = onClicked.Parent:FindFirstChild("Humanoid")
function onClicked(click)
if (click.Parent:FindFirstChild("Humanoid") ~= nil) then
    b.JumpPower = 500
    wait(10)
    b.JumpPower = 50
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

I'm a really terrible scripter, and it is probably extremely obvious for what is going wrong here, but I don't know. Also, when I click the part in-game, no errors appear in the console.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The reason why it is not working is because you are telling the script to find the humanoid even though you are using Click Detector!

Looks like you have not understood the concept of Click Detector.

What is Click Detector?

Click Detector is used for when you want a player to click a part and the part do a certain things.

How to use it

  • Start by inserting a part into workspace
  • After insert a Click Detector inside the part/brick
  • Then insert a script in side the Click Detector

Scripting it

To script open the script inside the Click Detector, and write the following...

script.Parent.mouseClick:Connect(function()

This tells the script that when the part is click, it have to Connect to the function. to write the function, simply just write it under the command you just wrote...

script.Parent.mouseClick:Connect(function()
script.Parent.Parent.Transparency = 1

This time we are telling the script that if the brick/Part is click, then we tell to make the script's parent's parent, which is the script's grandparent, which is also known as the brick. and we are telling the script that if the brick got click, simply turn it's transparency to 1, which is invisible.

You simply just don't have to connect to the player's Humanoid, because you are just clicking it.

If you have any question, just ask me.

All done! Have fun scripting your game! :D

But RainbowBeast aren't you forgetting something?

Ummm, oh yeah, I forget about the humanoid thing!

Let me example

The Humanoid command is for when you want the part to be touched.

But why do we need to use the command?

It is pretty simple if you think about it.

Sometimes not always a player will touch the brick, for example, something else might touch the brick, like another brick. So, you don't want the script to run when it's not a player who touches it.

So what do you do? You guessed it, use the humanoid command, which is basically a command that tells the script when something touched the brick, check if it has humanoid, humanoid is basically something that only human/ player have.

And that is pretty much it!

Have fun!

tell if I miss anything!

-RainbowBeastYT :D

0
its MouseClick, not mouseClick User#19524 175 — 6y
0
ok RainbowBeastYT 85 — 6y
Ad

Answer this question