Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

DataStore works fine when only one person is ingame, but changes everyone's values with multiple?

Asked by
Vid_eo 126
6 years ago

This datastore always works with the money, by the way. My issue is that the values in ReplicatedStorage change whenever someone else joins the server, and that replicates to all the clients.

LocalScript inside of Dances folder:

01local loadAnimEvent = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("loadAnimEvent")
02 
03loadAnimEvent.OnClientEvent:connect(function(plr)
04    print("dances loadin'")
05    local plr = game.Players.LocalPlayer
06    for i,e in pairs (game.ReplicatedStorage.danceValues:GetChildren()) do
07        if e:IsA("BoolValue") and e.Value == true then
08            print(e)
09            for i,v in pairs (plr.PlayerGui.Dances:GetChildren()) do
10                if v:IsA("TextButton") and v.Name == e.Name then
11                    v:Clone().Parent = plr.PlayerGui.dancesGui.dancesFrame.danceFrame.danceScrolling
12                end
13            end
14        end
15    end
16end)

DataStore script:

01local DataStoreService = game:GetService("DataStoreService")
02local ds = DataStoreService:GetDataStore("danceSave")
03local ds2 = DataStoreService:GetDataStore("MoneySave")
04 
05game:GetService("Players").PlayerAdded:Connect(function(Player) --When the player joins the game, load value.
06 
07    local Stats = Instance.new('Folder')
08    Stats.Name = "leaderstats"
09 
10    local Money = Instance.new('NumberValue', Stats)
11    Money.Name = "Money"
12 
13    Stats.Parent = Player
14 
15 
View all 94 lines...

Could this be fixed if I replicated the Folder with the dances in ReplicatedStorage to the player whenever the player joins? And then refer to the player instead of ReplicatedStorage?

Thanks.

0
ReplicatedStorage is "a container whose contents are replicated **to the server and all clients**. If you mean to store and change data to your client (locally), you should try something else. SulaymanArafat 230 — 6y
0
I suggest you use the same datastore but different keys to store different values. Operation_Meme 890 — 6y

1 answer

Log in to vote
2
Answered by
Dog2puppy 168
6 years ago

This appears to be happening because every client is using the same "dance values" that are in Replicated Storage. To fix this, just make new "dance values" for each player.

0
Would it also work if I automatically put the Dance values into the Player whenever they joined? And then accessed those dance values instead of the ones in ReplicatedStorage? Vid_eo 126 — 6y
0
Yes. Dog2puppy 168 — 6y
Ad

Answer this question