#Want it so that Cracked Lava Kills the player

28 messages · Page 1 of 1 (latest)

hushed trellis
#

Instead of having to place invisible killing blocks on every single patch of cracked lava in my game. Is there any way I can make it so the material itself will kill the player if they walk on it?

cloud sail
#

You can check if Humanoid.FloorMaterial is Enum.Material.CrackedLava and kill the player.

hushed trellis
cloud sail
#

~~You can detect a change in a specific property like so:

Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
    if Humanoid.FloorMaterial == Enum.Material.CrackedLava then
        Humanoid.Health = 0
    end
end)
```~~
#

Just remember that, if a player dies, their Humanoid is replaced, so connect the above event everytime the player dies.

#

Actually, there is a better way, or simpler.

#

--

#
  • Put a Script inside of game.StarterPlayer.StarterCharacterScripts. This will put whatever scripts inside that folder into the character on respawn.

  • Paste in this code:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
    if humanoid.FloorMaterial == Enum.Material.CrackedLava then
        humanoid.Health = 0
    end
end)
hushed trellis
#

k

#

this doesn't work @cloud sail

cloud sail
#

Any errors?

#

Show the output window.

hushed trellis
cloud sail
#

Send whatever errors you get, unless it is a plugin error, okay? Because lets us how what is wrong.

I have modified the code and hopefully it will work now. Just a little typo.

hushed trellis
#

ok

#

ooo looking good

#

before the Humanoid was underlined in red

#

now it isn't

cloud sail
#

Okay, you should mention that as well, because it indicates errors.

#

Does it work now?

hushed trellis
#

mb i forgot

hushed trellis
#

yes!

cloud sail
#

Okay good, now mark the post as ✅ Solved by tagging.

hushed trellis
#

success

#

done