local player = game.Players.LocalPlayer
local leaderstats = game.Players.leaderstats
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if player.leaderstats.Wins.Value >= 100 then
script.SkilledTag:Clone().Parent = char.Head
end
end)
end)
As you can see, billboardgui for tag is put inside the script:
Basically I want that when the player achieves 100 wins, he has the tag above his head.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local leaderstats = plr.leaderstats
if plr.leaderstats.Wins.Value >= 100 then
script.SkilledTag:Clone().Parent = char.Head
end
end)
end)
In server scripts, you cannot define the player with game.Players.LocalPlayer.
The way to get the player in a server script is to pass them through the PlayerAdded event like you have done already.
First of all, you are checking the players wins only once.
You could add for example .Changed to constantly return the players wins to do this.
Code:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local leaderstats = plr:WaitForChild("leaderstats")
leaderstats.Wins.Changed:Connect(function(wins)
if wins >= 100 then
script.SkilledTag:Clone().Parent = char.Head
end
end)
end)
end)
Could you try this? And also, what is the name of your Wins value? I do not know what it is so it could be an error because it does not exist.
game.Players.PlayerAdded:Connect(function(player)
local wins = player:WaitForChild("leaderstats"):WaitForChild("Wins")
player.CharacterAdded:Connect(function(char)
wins.Changed:Connect(function(yea)
if yea >= 100 then
script.SkilledTag:Clone().Parent = char:WaitForChild("Head")
end
end)
end)
end)
No problem! Make sure to Solution any code that works. It makes people that research know that this has been approved by the person finding help, making it more easier for the people trying to find a script that works. I can tell you are new to devforum so take these tips to mind.
Exploiters can change their value on the client-side and get the name tag.
No one else will be able to see the name tag, only the affected player.
Change this to a server script to fix the issues above.
Keep in mind that the LocalPlayer does not exist on the server.
You’ll need to use the plr parameter which is automatically passed to Players.PlayerAdded.