Leaderstats not replicating at others screen

Hello community,

I have a problem:
I want to remove this:
image

I searched on this article: Experimental Mode to solve my problem, without sucess.
Then I saw also that the leaderstats are not replicating for other players (other players can’t see how much gold I have)

See here what I mean with not replicating

image What I see
image What others see

I think this with the leadeboard and the Experimental mode have a connection for their problems.

Here is my leaderstats script
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("WonSaveSystem")
local ds2 = datastore:GetDataStore("GoldSaveSystem")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
		local leaderstats = Instance.new("IntValue")
		leaderstats.Name = "leaderstats"
		leaderstats.Parent = Player

		local gold = Instance.new("IntValue")
		gold.Name = "Gold"
		gold.Value = 0
		gold.Parent = leaderstats

		local Won = Instance.new("IntValue")
		Won.Name = "Wins"
		Won.Value = 0
		Won.Parent = leaderstats

		Won.Value = ds1:GetAsync(Player.UserId) or 0
		ds1:SetAsync(Player.UserId, Won.Value)
 	
	Won.Changed:Connect(function()
		ds1:SetAsync(Player.UserId, Won.Value)
	end)
game.Players.PlayerRemoving:Connect(function()
		ds1:SetAsync(Player.UserId, Won.Value)
	end)
	gold.Changed:Connect(function()
	end)
end)

Other informations:

  • I have FilteringEnabled false
  • I went yet under my game and clicked on update game to newest versionimage

If you need more informations, be free to ask!
Thanks from DieStockEnte

The Gold value and Wins value is not replicating because you are changing these values on client side. To fix this, these values must be changed on server side.

I think this article may be useful to understand the Client-Server model: Client-Server Runtime | Documentation - Roblox Creator Hub

2 Likes

To fix the “game may not function as intented”

Play your game for atleast more than 30 seconds and refresh your page, it will be removed

1 Like

Also doing this will have no effect since its default whether you activate it or not

2 Likes

right.
I am changing the values with two local script that are connected with remote events.
It works like this:

  1. The first script sends every 2 seconds a value with the current player gold.
  2. The second script gets with an remote event a value (an amount of gold) this amount gets subsracted with the players gold value (for example: player.leaderstats.gold.value - valuefromevent )

But how should I change the values from the serverside?
If the gold.value is in leaderstats and leaderstats is inside the player

I saw this here: Leaderboard Data not showing changes for other people on my screen
and at this topic /\ was the problem that FilteringEnabled was on true
and on other themes, there was the problem with FilteringEnabled set on true at the problem of this here:
image

I try it to play it again 30 seconds long. I played today yet with some friends and still that was showing up.
Anyways I publish the game, play it for 1 minutes and reload then the website

You can change the value easily on server side by this line:

game.Players:WaitForChild(player.Name).leaderstats.Gold.Value = x

where x is a number of gold.

1 Like

ok, I will try that and then I say here if it worked :wink:

To change the leaderstat values from serverside you’ll need a script that will trigger a function whenever the remote event is fired.

Example:

local repStorage = game:GetService("ReplicatedStorage")
local winEvent = repStorage.WinEvent
local goldEvent = repStorage.GoldEvent

winEvent.OnServerEvent:Connect(function(player, stat)
	player.leaderstats.Wins.Value = stat
	--make sure to protect this function with a server side check so exploiters cant set their wins
end)

goldEvent.OnServerEvent:Connect(function(player, stat)
	player.leaderstats.Gold.Value = stat
	--make sure to protect this function with a server side check so exploiters cant set their gold
end)

I haven’t tested this code and it’s only an example on how to read events on the server.

Didn’t see that, thanks.

2 Likes

You forgot to add the .Value property to player.leaderstats.Gold and player.leaderstats.Wins

2 Likes

“Game may not function as intended.” shows up when you set FilteringEnabled to false. There’s no work-around and the only way to get rid of the message is to re-enable FilteringEnabled and play the game once. Here’s somebody else who had same message.

Other people had the right idea. Once FE is enabled, you’ll probably need to redesign your leaderstats system so the server updates the values for every client instead of clients updating it by themselves. Here’s an article with more info on FE. There’s a few other links at the bottom of that to read more.

4 Likes

Thanks everyone! Now everthing works perfectly.
Thanks @CriticCritic for your code and help! Thanks @KRZYMEN for your help and your good eye on the script of CriticCritic ;)! Thanks @FastAsFlash_Dev for your help with “Game may not function as intended” and thanks @Troidit for solving my problem on with the “Game may not function as intended”

Now I solved any problem. Together we solved all :slight_smile:

Sorry if I pinged you, but I wanted only to say thanks and to say that it works now.

2 Likes