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)
Change local humanoid = game:GetService("Players").LocalPlayer.Character
to local humanoid = game:GetService("Players").LocalPlayer.Character.Humanoid
.