Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
Edited 2 years ago

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)

0
Is the script a serverscript or a localscript? ShaShxa 105 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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

Ad

Answer this question