Hey I have a problem with a script (local script) that tells me Player.shaboogly123.PlayerGui.ChooseTeam.TeamJoin.JoinBlue.LocalScript:2: attempt to index field 'Character' (a nil value) when I'm in an actual game server, but in studio it works fine. The actual script is:
local player = game.Players.LocalPlayer
local torso = player.Character:WaitForChild("Torso")
script.Parent.MouseButton1Click:connect(function()
if (#game.Teams["Red Team"]:GetPlayers() > #game.Teams["Blue Team"]:GetPlayers()) then
script.Parent.Text = "Error, teams will result unbalanced"
wait(2)
script.Parent.Text = "Join Red"
elseif (#game.Teams["Red Team"]:GetPlayers() <= #game.Teams["Blue Team"]:GetPlayers()) then
player.TeamColor = BrickColor.new("Bright red")
torso.CFrame = CFrame.new(322.5, 2.001, 1838)
script.Parent.Parent.Visible = false
end
end)
I've tried removing the local from player and torso, but it didn't work. Line 2 is the problem and idk how to fix it or even why it errors

1 comment
Worked like a charm! Thanks!