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

Why won't this if statement work on a team switch part?

Asked by 4 years ago

I'm trying to make a block that switches the players team, no errors, it prints london and cornwall but it wont detect the players team for some reason.

local part = script.Parent
local axisteam = game.Teams.Axis
local alliesteam = game.Teams.Allies


part.Touched:Connect(function(object)
    if object.Name ~= "HumanoidRootPart" then return end
    local player = game.Players:GetPlayerFromCharacter(object.Parent)
    if player then
    print("London")
        local gui = player.PlayerGui.ExclusionZone
        local character = object.Parent
        local humanoid = character:FindFirstChildOfClass("Humanoid")
        if humanoid then
            print("Cornwall")
            if player.Team == alliesteam then
                print(" its allies ! ")
                player.Team = axisteam
                humanoid:TakeDamage(100)

            end
        end
    end
end)
0
make sure that property 'AutoAssignable' is off for both teams karesiku 72 — 4y
0
It is. @karesiku RedCoatOracuda 35 — 4y

Answer this question