I try to make a reset button, but the script doesn't work! The script I use is this:
1 | function onClicked(click) |
2 | script.parent.parent.parent.parent.Character.Humanoid.Health = 0 |
3 | end |
4 |
5 | script.parent.MouseButton 1 Click:connect(click) |
Mind if anyone can help?
Noticed that there was a mistake in my code below. Just fixed it. Mine should work.
Three Errors: 1. You're better off using a LocalScript. 2. You typed "Mouce" instead of "Mouse." 3. Parent needs a capital P.
Okay, first of all, are you using a LocalScript? If not, you should. Let me re-do your code for you. Put this code in a LocalScript in the place where you put your current script:
EDIT: Simplified the below code
1 | function click() |
2 | game.Players.LocalPlayer.Character.Humanoid.Health = 0 |
3 | end |
4 |
5 | script.Parent.MouseButton 1 Click:connect(click) |
That should do it.
1 | function onClicked() |
2 | game.Players.LocalPlayer.Character.Humanoid.Health = 0 |
3 | end |
4 |
5 | script.Parent.MouseButton 1 Down:connect(onClicked) |
Let me know if that works
Is it in a StarterGui and Frame and everything? I think you put too many Parents. Also it needs a capital P.
1 | function die() |
2 | script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 |
3 | end |
4 |
5 | script.Parent.MouseButton 1 Click:connect(die) |
I did a youtube video on this if you want,which kinda explains on why and how all the code works.
Here is what I did for mine in Reading club : Rewritten
1 | local Player = game.Players.LocalPlayer |
2 | function youknowalotabouttrucks() |
3 | Player.Character.Humanoid.Health = 0 |
4 | end |
5 | script.Parent.MouseButton 1 Down:Connect(youknowalotabouttrucks) |
lol