could i add others stuff like defense KI etc
i edited ur code fixed 2 errors and now it works thanks!
added more stats too in the script
in the server script
for v, ValueInstance in pairs(Player.leaderstats) do
if ValueInstance:IsA("ValueBase") then
Data[ValueInstance.Name] = ValueInstance.Value
end
end
this part had error
for v, ValueInstance in pairs(Player.leaderstats) do
the Player.leaderstats had error since the error said table expected so i changed it to this
local mainstats = Player.MainStats
for v, ValueInstance in pairs(mainstats) do
if ValueInstance:IsA("ValueBase") then
Data[ValueInstance.Name] = ValueInstance.Value
end
end
Oh my bad you only have to do this :
for v, ValueInstance in pairs(Player.leaderstats:GetChildren()) do
can i use my version which i use now also idk how to make bindtoclose so ye
No you can’t since in my script I’m getting leaderstats children and I don’t understand what you want to make with bind to close ?
i heard that you need to keep bindtoclose
also idk since my version still works
I took a look at your code and I don’t understand cause in your old code you were trying to save players data when the server shut down but you’re already saving their data when they leave so you don’t need to keep !
EDIT : plus you’re trying to get player but they doesn’t exist since they leaved the game !
I will update the message where I send you the code !
i know since i keep getting this error BindToClose failed because the model is already being closed.
oops in mine code this is the part i forgot to look in my code
local mainstats = Player.Gmultis:GetChildren()
for v, ValueInstance in pairs(mainstats) do
if ValueInstance:IsA("ValueBase") then
Data[ValueInstance.Name] = ValueInstance.Value
end
end
You don’t need mainstats since you can do Player.leaderstats:GetChildren() !
yeah i know but ill keep it since it still works so ye
i use 4 different leaderstats scripts since in 1 script a lot of them wont be created
hi back again! here’s a link to a similar issue i just helped a guy with
to use game:BindToClose(function()
as shown im my post
yeah since that i improved in scripting a lot now mostly i dont get errors and if i do i can fix them easily
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.