Script does not change based on leaderstat

Hello, this script should change when a leaderstat is changed. I have a script that changes a users leaderstat based on team and group rank. This script should check the rank and update it if the leaderstat changes on a user and showcase it,

Script:


script.Parent.Text = "" .. game.Players.LocalPlayer.leaderstats.Rank.Value 
while wait(1) do
	script.Parent.Text = "" .. game.Players.LocalPlayer.leaderstats.Rank.Value 
end

No console errors

Are you updating the leader board from the server or from a local script?

Server script. 20 CHARRRSSS

So your 100% certain you change it on the server?

If so, where is the chunk of code that changes the stats?

It 100% changes on the server

local Security = 11200509


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		local leaderstats = Instance.new("Folder",player)
		leaderstats.Name = "leaderstats"
		local rank = Instance.new("StringValue",leaderstats)
		rank.Name = "Rank"
		
	
		if player.Team == game.Teams["Joining"] then
	rank.Value = player:GetRoleInGroup(SCP)
	
		elseif player.Team == game.Teams["Class D"] then
			rank.Value = player:GetRoleInGroup(Security)
		
			
		end
	end)
end)```

Alright, when you join the game your player needs to be assigned to a team before this script runs.

Have you made sure that the player is assigned a team before the if statement runs?

The user is assigned a team yes.

The user is automatically teamed Joining while in the menu.

The leaderboard works fully. The issue is with the top script

Try doing:

print(game.Players.LocalPlayer.leaderstats.Rank.Value)

Then see what it prints.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.