Errors with my script

Hi,
I wrote a script and it works but i have errors in output.
Here’s script:

script.Parent.Touched:Connect(function(hit)
	local char = hit.Parent.Humanoid
	local plr = game:GetService("Players"):GetPlayerFromCharacter(char)
	if char ~= nil and plr.Team ~= game:GetService("Teams").WaterOrb then
		char.Health = 0
	end
end)

Here’s error:
Workspace.WO.BaseDoorWO.Script:4: attempt to index nil with ‘Team’
It shows when I touch the part

You’re trying to get a playerfrom a Humanoid

script.Parent.Touched:Connect(function(hit)
	local char = hit.Parent
	local humanoid = char:FindFirstChild("Humanoid")
	local plr = game:GetService("Players"):GetPlayerFromCharacter(char)
	if humanoid and plr and plr.Team ~= game:GetService("Teams").WaterOrb then
		humanoid.Health = 0
	end
end)

Edit: god i should’ve double checked this post

2 Likes

Um what is “WaterOrb” as you have not defined it have you?

Oops sorry for the reply to you Embat.

1 Like

WaterOrb is my team name xD…