So I'm trying to make a script that will find the players team once the tool is activated. After I activate it on test, it comes up in output with " Players.NortonHDD.Backpack.tool.Script:7: attempt to index nil with 'Team'"
Anyone able to help me out on this? Below is my code.
debounce = true
tool = script.Parent
local Red = game.Teams.Red
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
function onActivation()
while true do
if player.Team == Red then
debounce = false
print("Works")
wait(5)
debounce = true
end
end
end
tool.Activated:Connect(onActivation)

2 comments
I remove the "While true do" and it does the same thing.
First Your Script Need This local TC = Instance.new("RemoteEvent") TC.Name = "TeamChanger" TC.Parent = game.ReplicatedStorage TC.OnServerEvent:Connect(function(Player, TeamName) Player.Team = game.Teams[TeamName] Player:LoadCharacter() end) | If Your Button Click Script Doesn't works try this: function Click(mouse) if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(00000) then --Replace