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

My team checking script won't work?


Summary

My script is supposed to check if a player is a certain team to prevent players from going into the opposite teams base, but it just throws a error and does nothing.


Error

Team is not a valid member of player


Script

script.Parent.Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player.Team == "Bright red Team" then
		player:BreakJoints()
	end
end)

1 comment

0

updated

1 answer

It's TeamColor, and TeamColor is a BrickColor value, you don't use the name. Also, You cannot call breakjoints on the player, but on the character instead.

script.Parent.Touched:connect(function(hit)
	local h = hit.Parent:WaitForChild("Humanoid")
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player.TeamColor  == BrickColor.new("Bright red") then
        player.Character:BreakJoints()
    end
end)

Hope it helps!

1 comment

0

Workspace.RedArea.TeamChecker.Checker:3: attempt to index local 'player' (a nil value)

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