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)

2 comments

0

make sure that property 'AutoAssignable' is off for both teams

0

It is. @karesiku