#SavaData problem
107 messages · Page 1 of 1 (latest)
On line 124, 'data' is reffering to an unknown global. You need to create a local variable above the 'pcall' and define data
In simpler terms, put 'local data' on line 122
i will try that
did not work still same problem
I left the game and rejoin and the value did not save
@white pollen
Do you have Studio Access to API Services enabled?
Also what is your output saying?
yes it is enable and it was saying cant convert it to number
i am using a int value does that matter
@white pollen
Ohh I see the problem
line 139 make sure you pass the Hair.Value instead of the instance
ok
So line 139 would be
HairData:SetAsync(player.UserId..'-Hair', player.Character.Hair.Value)
did not work
i check and it is suppose to be UserId
I replace player.Character.Hair.Value with 500 and it worked'
so the problem is that its not getting the number from player.Character.Hair.Value
not sure why tho
@white pollen
What's the error message it's giving you?
currently it is not giving a error because i put a value of 500 and its always loads up since there is no new number to replace it
@white pollen
Can you send a screenshot?
@white pollen
You should use the studio output bar
Can you send a screenshot of the updated script?
ok
i put 500 just to test if the rest of the script was working and it does just can find hair value
and now 500 is in save now
Now if you play the game, switch to the server and change the value, does it save properly?
Hmm
I honestly have no idea
And you replaced the '500' with Player.Character.Hair.Value, right?
Give me a summary, @patent jewel
ok
so basically everything works execpt getting the number from the int value inside of the player, and it wont save
** You are now Level 7! **
You're not handling the case in which the server shuts down
Convert your Players.PlayerRemoving handler from a throwaway function to a named function:
game.Players.PlayerRemoving:Connect(function(player)
-- ...
end)
-- To:
local function saveData(player: Player)
-- ...
end
Players.PlayerRemoving:Connect(saveData)
This gives you access to the data-saving logic elsewhere in your script. You will then need to bind a callback to the server-shutdown process, which can be done so through game:BindToClose:
game:BindToClose(function()
-- Because your code makes several references to game.Players, it should be stored in a variable.
for _, player in Players:GetPlayers() do
saveData(player)
end
end)
** You are now Level 42! **
You should know that Roblox does not guarantee the execution order of your scripts. The following code has the chance to run before Hair is added to the player's character:
You should use Instance:WaitForChild to access that child
@sonic portal
Look at this carefully
Now look back at where I told you to use WaitForChild
Look again
@sonic portal
the problem is not that it does not save the problem is that hair.value does not give a number value
if i replace it with a number when it safes its works
For some reason it does not access the data from the intvalue
I am thinking the problem is that it cant acces the hair value because the player is gone
Make sure to define data as local to your Players.PlayerAdded handler. This must be done outside of your pcall so it may be known to your if-statement
Yes, that is correct
Store that information in the player
@sonic portal
nevermind I put in playerscripts
I know this is wrong but where do I put the information in player? @sonic portal
it say debugging
@sonic portal brakes not sure why
local playername = player.Name
playername.hairFolder.Hair.Value = 1
fixed it
does not work
@sonic portal
You must create the IntValue and place it under the Player instance
You're also accessing the wrong GUI
StarterGui is nothing but a storage container. Because each client has their own monitor and experience with the UI, its contents are copied and transferred to a folder within the player called "PlayerGui"
That's where the rendered GUIs exist
So how do you know that the data isn't loading?
i join the game leave and rejoin and check inside player to see if the hair value is the same as when i lefted
When I switch hairs it changes the value of hair.value
for example there are 5 hairs, and if the player leaves it at the fourh hair the number changes to 4 but when i leave and rejoin its not 4
@sonic portal
Are you changing that value from the server?
yes