I made a while loop where it prints the players team, how ever, when the player changes team, the printing hasn’t changed to the team that the player recently changed
while task.wait(1) do
print(player.Team)
if player.Team == teams["pro"] then
times.Value += 1
end
end
end
player’s team turns to pro BUT the print statement prints out another team (which is noob)
What’s the teams variable?
This text will be blurred
I havent made variables for them, if youre thinking of names. noob and pro, i start as noob team but as i switch the print statement keeps printing noob
No what is the teams[“pro”] variable?
This text will be blurred
Does the times value successfully increment after changing the team?
teams is
local teams = game:GetService("Teams")
No since it prints out noob, so that means the if statement is false since im still noob accord to print statement
Where does it change the teams?
It changes team after i leave the safe zone in a safezone enter and exit script using zoneplus
Instead of checking if the team is equal to teams[“pro”].
Try checking according to the color of the teams.
E.G.
if player.TeamColor == BrickColor.new("Bright red") then
print("they're in this team")
end
But in your case, change the Bright red to the colour of the pro team
I’m pretty sure it’s that script that’s having the problem.
- What type of script is that?
- What’s the content?
- Are the teams spelled correctly?
- it is an normal script not local
- Contents in this script includes all of this
local Players = game:GetService("Players")
local teams = game:GetService("Teams")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local times = Instance.new("IntValue")
times.Name = "times"
times.Value = 0
times.Parent = leaderstats
while task.wait() do
print(player.Team)
if player.TeamColor == BrickColor.new("Bright red") then
print("they're in this team")
end
end
end
Players.PlayerAdded:Connect(leaderboardSetup)
Yes, team is spelt correctly
This didnt work sadly, printed nothing
I meant the one that changes the teams sorry.
This text will be blurred
What is the colour of the ‘pro’ team under Teams
local rs = game:GetService("ReplicatedStorage")
local zone = require(rs.Zone)
local zonecontroller = require(rs.Zone.ZoneController)
local Teams = game:GetService("Teams")
local simple = game.Workspace.teams
local teamzone = zone.new(simple)
local players = game:GetService("Players")
local localplr = players.LocalPlayer
teamzone.playerEntered:Connect(function(player)
print(("%s entered the zone!"):format(player.Name))
--localplr.Team = game:GetService("Teams")[Team]
localplr.Team = game:GetService("Teams")["noobs"]
end)
teamzone.playerExited:Connect(function(player)
print(("%s left the zone!"):format(player.Name))
--localplr.Team = game:GetService("Teams")[Team]
if localplr then
localplr.Team = game:GetService("Teams")["pro"]
--localplr.Character:WaitForChild("getplr").Value = true
end
end)
Bright red is the colour of ‘pro’ team
It appears as though your problem is in the changing script.
Wrong: localplr.Team = game:GetService("Teams")["pro"]
Correct: localplr.Team = game:GetService("Teams")["pro"].TeamColor
I get an error when i do this, Unable to assign property Team. Object expected, got BrickColor
Oh another change localplr.Team
→ localplr.TeamColor