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

My team checking script won't work?

Asked by
Relatch 550 Moderation Voter
8 years ago

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)
0
updated EzraNehemiah_TF2 3552 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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!

0
Workspace.RedArea.TeamChecker.Checker:3: attempt to index local 'player' (a nil value) Relatch 550 — 8y
Ad

Answer this question