1 | Lava = game.Workspace.Lava |
2 |
3 | function onTouched(Lava) |
4 | function PlayerWhoOnTouchedLava(game.Workspace:onTouched(Lava)) |
5 | PlayerWhoOnTouchedLava.Humanoid = 0 |
6 | end |
7 | end |
When you step on the brick, you die. But it won't do that. The funcion PlayerWhoOnTouchedLava() is the person who touched lava, It won't work. Why?
Well first off, there are many errors in your script. This would be the correct way of writing it:
1 | local Lava = game.Workspace.Lava |
2 | function onTouched(Obj) --The function that gets called when Lava is touched |
3 | if Obj.Parent:FindFirstChild( "Humanoid" ) then --Checks to make sure there is a humanoid |
4 | Obj.Parent.Humanoid.Health = 0 --Makes the health of that humanoid 0 |
5 | end |
6 | end |
7 | Lava.Touched:connect(onTouched) --connects the Touched event to the onTouched function |
Hope this helped!
You set 'Lava' as a parameter, and parameters only apply to the function in which they are given in. Thus, meaning, your variable is nil. Best way to do this is by checking for the part's humanoid that touched the brick.
1 | function onTouched(part) |
2 | human = part.Parent:findFirstChild( "Humanoid" ) --Finds the humanoid of the part that touched |
3 | if (human ~ = nil ) then --If humanoid does exist |
4 | human.Health = 0 --Sets health at 0, causing death |
5 | end |
6 | end --You need and end for the function, and another end for the if statement. |
7 |
8 | script.Parent.Touched:connect(onTouched) --Connection line |
If you have any other problems, feel free to inbox me.
~Kyo-Chan
When I saw PlayerWhoOnTouchedLava, then a second function straight after it. I lol'd XD