Hi devs,
I have a problem with my datastroe.
The value saved on studio on the client and when I retest the game the value is saving, but the value its ZERO when I switch to the server.
I tested a lot and different Datastorage.
I have part in workspace with a script. When the value is >5 then part destroy. When the value is on client bigger then 5 is doenst work, but when I change the value at 6 on the server the part is destroyed.
Please help me so I can finish my game.
Thx
The script in the part in workspace:
local owner = script.Parent.Parent.Parent.Parent.TycoonInfo:FindFirstChild(âOwnerâ)
local plr = owner.Value
local star = plr:WaitForChild(âStarsTestâ).StarsCollected
while true do
wait(.1)
if star.Value > 5 then -- 6 Stars
print("OPEN")
script.Parent:Destroy()
break
end
A Value instance (i.e. a StringValue, NumberValue, etc.) is not the same as a Datastore. Datastores are a bit more complex, and you can read more about them here: Data Stores | Roblox Creator Documentation
When something changes on the server, it changes on all of the clients. This is known as replication. However, when something changes on a client, it doesnât change on the server. Otherwise, a hacker would be able to change their own client (for example, giving themselves a load of money), replicate that change to the server, and then also replicate those changes to all the other clients.
This would be a massive security risk, as there is nothing you can do to stop a hacker from changing their client.
The way this is impacting you is that youâre changing the StarsCollected value on the client (anything in the Workspace is on the client), which doesnât replicate to the server (for the security reasons discussed earlier), which is why on the server nothing appears to be changing.
I tried but its hard. A another question, how can i make a part in workspace destroyed when a value rich foe example â5â stars on leaderstat? Because the textlebal with the star value works fine.