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

I need help with a lava script [?]

this lava script is supposed to only kill someone if they are not on a certain team, but I cant seem to be able to access the players TeamColor correctly.

function onTouch(part) 
local humanoid = part.Parent:FindFirstChild("Humanoid") 
if (humanoid ~= nil) then
	if part.Parent.Player.TeamColor ~= 	script.Parent.Parent.Parent.Parent.Parent.TeamColor.Value then	
	humanoid.Health = 0	-- damage the humanoid
end 
end
end

script.Parent.Touched:connect(onTouch)

1 answer

✓ Accepted answer

Do :GetPlayerFromCharacter() like:

local player = game.Players:GetPlayerFromCharacter(part.Parent) -- then do
if player.TeamColor ~= script.Parent.Parent.Parent.Parent.Parent.TeamColor.Value then
humanoid.Health = 0
end

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