Script problem!

  1. What do you want to achieve?
    I want to all the player have his own amount of money !
  2. What is the issue?
    All of the player have the same amount of money !
  3. What solutions have you tried so far?
    I have tried this :
local Player = game.Players
local DataStoreService = game:GetService("DataStoreService")

local DataStoreFDW = DataStoreService:GetDataStore("FDW")
local RemoteEventFDW = game.ReplicatedStorage.FDW
local FDW = script.FDW

local DataStoreFirstJoin = DataStoreService:GetDataStore("FirstJoin")
local FirstJoin

Player.PlayerAdded:Connect(function(player)
	FDW.Value = DataStoreFDW:GetAsync(player.UserId)
	FirstJoin = DataStoreFirstJoin:GetAsync(player.UserId)
	if FirstJoin == nil then
		FDW.Value = 0
		FDW.Value = FDW.Value + 50
		FirstJoin = false
		DataStoreFirstJoin:SetAsync(player.UserId, FirstJoin)
	else
		FDW.Value = FDW.Value + 50
	end
end)

Player.PlayerRemoving:Connect(function(player)
	FDW.Value = FDW.Value + 10
	DataStoreFDW:SetAsync(player.UserId, FDW.Value)
end)

FDW:GetPropertyChangedSignal("Value"):Connect(function()
	RemoteEventFDW:FireAllClients(FDW.Value)
end)

Have a nice day ! :yum:

1 Like

I assume FDW is some sort of script, however it’s not a client script meaning that it’s not being duplicated individually to each player separately, meaning that one player will override the last one and whenever a new player joins it’ll just happen over again.

1 Like

Thank you I’m so stupid sorry ! :sweat_smile:

But data store can’t be accessed from client ! :thinking:

You’ll have to use some other form of data storage to store it then. You can use a table of values, a folder of IntValues or whatever type you’re using here, etc.

1 Like

This script need to be client is this no ? :face_with_raised_eyebrow::thinking:

No, it doesn’t need to be on the client. It’s data management so it should be done on the server anyway.

1 Like

Hmm … I got it, this is the other script :

local RemoteEventFDW = game.ReplicatedStorage.FDW

RemoteEventFDW.OnClientEvent:Connect(function(FDW)
	script.Parent.LabelFWD.Text = tostring(FDW.." ".."FDW")
end)

It is a local script in starter gui ! :grin:

Maybe it’s FireAllClients the problem ? :thinking:

The problem hasn’t changed. All clients will be replicated a script which connects to that 1 remote. As you only have one data set for FDW, everyone shares that data as the info get’s sent to everybody.

1 Like

local Player = game:GetService("Players") --yields the script until the service is loaded
same goes to this

again, yield the script until ReplicatedStorage is found AND the instance “FDW” is found
local RemoteEventFDW = game:GetService("ReplicatedStorage"):WaitForChild("FDW")
are you doing this in a ServerScript or LocalScript?

2 Likes

Let me see before so that again that’s script That’s a problem we know this maybe you have the problem issues we have a fix but other day but But I’m just testing them if that is working game

Server script ! :grin:
And my way is the same as you no ? :thinking:

But we know this is a server Just we are just in our game we know this that’s a big problem is coming to error

I don’t understand sorry (fredfhdrhh) … :sweat_smile:

game:GetService() yields the script until a certain service is found
yes, you did that once but they were only done on certain functions not found in explorer
your way??? get the services blindly without making sure it can be found

ehhhh somewhat slightly different

1 Like

Hmm … But that is not the problem my script work but all the player have the same amount of money … :neutral_face:

If that’s what you don’t understand, there are 2 types

Client: A local one, for players

Server: Same for everyone, that’s why DSS can’t be accessed from a client sided script. You should use Scripts instead of the Local Scripts

EDIT: I didn’t mean that you should use server scripts for everything, but use them for DataStoreService.

1 Like

Thank you, but I know already that ! :grinning::wink:
I think the problem is maybe the remote event … :thinking::neutral_face:

1 Like

Can you tell me how much money they have? So I can analyse it.

Also do not use local scripts to load datas