local RP = game:GetService("ReplicatedStorage")
local PlayerTags = RP.PlayerTags
local player = game:GetService("Players")
local PoliceLevel = player:GetChildren("leaderstats").PoliceLevel
local CriminalLevel = player:GetChildren("leaderstats").CriminalLevel
game:WaitForChild("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local head = char.Head
local PlayerLevelText = PlayerTags.PlayerLevelText
local PlayerNameText = PlayerTags.PlayerNameText
PlayerTags.Parent = head
PlayerTags.Adornee = head
if player.Team == "Criminal" then
PlayerLevelText.Text = "Lv: "..player.CriminalLevel.Value
elseif player.Team == "Police" then
PlayerLevelText.Text = "Lv:"..player.PoliceLevel.Value
end
PlayerNameText.Text = player.Name
end)
end)
I want when the player is in the police team, the text will be equals his level in that team. And so when he’s in criminal, but it doesn’t work for some reason, even no errors
These lines dont make sense. player represents here a service, not the local player.
Try this code:
local RP = game:GetService("ReplicatedStorage")
local PlayerTags = RP.PlayerTags
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local head = char.Head
local PlayerLevelText = PlayerTags.PlayerLevelText:Clone()
local PlayerNameText = PlayerTags.PlayerNameText:Clone()
PlayerTags.Parent = head
PlayerTags.Adornee = head
if player.Team == Teams:FindFirstChild("Criminals") then
PlayerLevelText.Text = "Lv: "..player.CriminalLevel.Value
elseif player.Team == Teams:FindFirstChild("Police") then
PlayerLevelText.Text = "Lv:"..player.PoliceLevel.Value
end
PlayerNameText.Text = player.Name
end)
end)
I also believe you’d have to clone those Tags into each player when they join the game.
local RP = game:GetService("ReplicatedStorage")
local PlayerTags = RP.PlayerTags
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
Players.PlayerAdded:Connect(function(player)
print(player.Name.." has arrived")
player.CharacterAdded:Connect(function(char)
print(char.Name.." has arrived in the world")
local head = char.Head
local PlayerLevelText = PlayerTags.PlayerLevelText:Clone()
local PlayerNameText = PlayerTags.PlayerNameText:Clone()
PlayerTags.Parent = head
PlayerTags.Adornee = head
print("Success")
if player.Team == Teams:FindFirstChild("Criminals") then
PlayerLevelText.Text = "Lv: "..player.CriminalLevel.Value
elseif player.Team == Teams:FindFirstChild("Police") then
PlayerLevelText.Text = "Lv:"..player.PoliceLevel.Value
end
PlayerNameText.Text = player.Name
end)
end)
PlayerTags.Parent = head
PlayerTags.Adornee = head
Since, local PlayerTags = RP.PlayerTags represents a folder[ I assume], or a model.
It doesnt have an Adornee property.
To fix that, try this -
local RP = game:GetService("ReplicatedStorage")
local PlayerTags = RP.PlayerTags
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
Players.PlayerAdded:Connect(function(player)
print(player.Name.." has arrived")
player.CharacterAdded:Connect(function(char)
print(char.Name.." has arrived in the world")
local head = char.Head
local PlayerLevelText = PlayerTags.PlayerLevelText:Clone()
local PlayerNameText = PlayerTags.PlayerNameText:Clone()
PlayerLevelText .Parent = head
PlayerNameText .Parent = head
PlayerLevelText .Adornee = head
PlayerNameText .Adornee = head
print("Success")
if player.Team == Teams:FindFirstChild("Criminals") then
PlayerLevelText.Text = "Lv: "..player.CriminalLevel.Value
elseif player.Team == Teams:FindFirstChild("Police") then
PlayerLevelText.Text = "Lv:"..player.PoliceLevel.Value
end
PlayerNameText.Text = player.Name
end)
end)
Tho, I suggest having 1 tag, containing 2 textlabels/frames,etc and name of PlayerNameText, and the other PlayerLevelText.
I mean, I just don’t know why it won’t just print in the next tag the player team level value. It prints the text in the properties but not in the script for some reason.