I have a problem, Roblox doesn’t understand what he needs. I have 2 leaderstats with the the same name. Let’s say I have leaderstats.value.cash and leaderstats.value.level, well, and roblox does not understand what i mean!
did you actually add a leaderstats folder/value to the player?
What do you meen? I don’t really understand
Use :WaitForChild().
For more information: Instance | Roblox Creator Documentation
Here is example:
local Part = game.Workspace:WaitForChild("Part")
The WaitForChild basicly wait until find somthing you want from them, then run code.
Since it said: “leaderstats is not a vaild member of…etc.” It didn’t founded leaderstats in CotRobloxGame. You may use :WaitForChild(“leaderstats”) or check what’s inside of CotRobloxGame.
Leaderstats needs to be a folder within the player, as @supergreatr299 rightfully said. It can’t be a value, instance, etc, it can only be a folder with the name “leaderstats”. If you are making this folder and putting it in the player, the script accessing it may be referencing it too soon, all though that is unlikely.
Could you provide some sort of code so that we may see the issue?
Nothing ever calls the onPlayerEntered function so you need to connect it up to an event such as:
game.Players.PlayerAdded:Connect(function(newPlayer)
end)
Try something like this:
game.Players.PlayerAdded:Connect(function(plr)
local Folder = Instance.new("Folder", plr)
Folder.Name = "leaderstats"
local Cash = Instance.new("IntValue", Folder)
Cash.Name = Score
Cash.Value = 0
local Seconds = Instance.new("IntValue", Folder)
Seconds.Name = "Time"
Seconds.Value = 0
end)
game.Players.PlayerAdded:connect(function(newPlayer) should help.
And i need make DataStore but dont working
DataStore script:
local ds = game:GetService(“DataStoreService”):GetDataStore(“SaveData”)
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = “id_”…plr.UserId
local save1 = plr.leaderstats.Cash
local save2 = plr.leaderstats.Time
local GetSaved = ds:GetAsync(plrkey)
if GetSaved then
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
else
local NumberForSaving = {save1.Value}
ds:GetAsync(plrkey, NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync(“id_”…plr.UserId,{plr.leaderstats.Cash.Value, plr.leaderstats.Time.Value})
end)
Remove this part. GetAsync does not take two arguments.
Nothing works for me, what should I do?
Thank you so much, i’ve been thinking for 4 hours.
I am bad scripter