The problem in my script is at line 9, the playerInf folder is in the LocalPlayer, and inside it is the intValue named teamPicked, and it cant change because of "attempt to index nil" my script to change the teamPicked value :
local cam = workspace:WaitForChild("Camera")
player = script.Parent.Parent.Parent.Parent
function onClicked()
player.TeamColor = BrickColor.new("Bright red")
player.Team = game.Teams.Red
local character = game.Workspace:FindFirstChild(player.Name)
character:findFirstChild("Humanoid").Health = 0
cam.CameraType = "Scriptable"
game.Players.LocalPlayer.playerInf.teamPicked.Value = 1
end
script.Parent.MouseButton1Down:connect(onClicked)
my script for the Instance.new that creates the folder and intValue:
local player = game.Players.LocalPlayer
local teamPickedInfo = Instance.new("Folder", player)
teamPickedInfo.Name = "playerInf"
local teamPickedValue = Instance.new("IntValue",teamPickedInfo)
teamPickedValue.Name = "teamPicked"
teamPickedValue.Value = 0

1 comment
player = script.Parent.Parent.Parent.Parent could be the problem. - not a loalscript?