Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I damage someone when they step on a certain type of Terrain?

Hi! I am working on a story game and have been trying to damage people when they touch a certain terrain type, but it does not work. Can somebody help? Thanks!

local humanoid = game:GetService("Players").LocalPlayer.Character local playerHealth = humanoid.Health local terrain = game.Workspace.Terrain if (humanoid.FloorMaterial == Enum.Material.CrackedLava) then playerHealth = playerHealth - 1 print("HOT! HOT") else print("NOT HOT!") end

I also get an error that reads Workspace.BurnScript:1: attempt to index nil with 'Character' - Server - BurnScript:1

Please help! (P.S. BurnScript is the name of the script the code is in)

1 comment

0

Is the script a serverscript or a localscript?

1 answer

Change local humanoid = game:GetService("Players").LocalPlayer.Character to local humanoid = game:GetService("Players").LocalPlayer.Character.Humanoid.

This discussion is preserved as it was. New answers, comments, and votes are closed.