Ok, I edited my script from before so it doesn’t require you to combine them (it just waits for it to be created instead).
yah but dose your script save, like the leaderstats?
No, your script already does that.
all im trying to do is basicly make a door like the doors off of pet simulator were you have to pay to go into the next area, but i dont know how to do that so i just am doing 2 leaderstats and making it so if a player has that amount of areas or more areas they can go through
If this is a localscript, it can be exploited pretty easily.
You should be really careful what power you’re giving the client.
Besides, also do some sanity checks on the server before giving them anything (via the server).
When they click to change their stats by clicking on the button,
other players won’t be able to see it as the change is local (only affecting the player doing it).
You can use a RemoteEvent to solve this: RemoteEvent
Also. You shouldn’t use SetAsync() everytime their stats is changed, you will have throttling issues.
You should load their data when they join, and save when:
- Leaving (PlayerRemoving)
- Interval
while wait(180) do SaveData() end
- BindToClose
Another note
LuaU has something new you can use.
Instead of doing: Cash.Value = Cash.Value + 1
,
you could do: Cash.Value += 1
.
These also counts for: %
, /
, -
and +
(I believe that’s all of them).
Useful links
Data-related:
BindToClose:
About Async:
Every time You do any thing with “Async” you should put it in a pcall:
pcall(function()
ContentProvide:PreloadAsync()
DataStore:GetAsync()
DataStore:SetAsync()
end)
Its generaly a good practise.