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

I need help with a lava script [?]

Asked by 8 years ago

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

Log in to vote
0
Answered by
Decemus 141
8 years ago

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
Ad

Answer this question