#SavaData problem

107 messages · Page 1 of 1 (latest)

patent jewel
#

player.character.Hair.Value is not working and not giving a value but when I replace it with a number it does work so its not loading the problem but instead finding the hair value inside the player not working

white pollen
#

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

patent jewel
#

i will try that

#

did not work still same problem

#

I left the game and rejoin and the value did not save

patent jewel
white pollen
#

Do you have Studio Access to API Services enabled?

#

Also what is your output saying?

patent jewel
#

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

patent jewel
#

ok

white pollen
#

So line 139 would be

HairData:SetAsync(player.UserId..'-Hair', player.Character.Hair.Value)
patent jewel
#

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
patent jewel
#

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

white pollen
#

Can you send a screenshot?

patent jewel
#

ok

patent jewel
white pollen
#

You should use the studio output bar

#

Can you send a screenshot of the updated script?

patent jewel
#

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

white pollen
#

Now if you play the game, switch to the server and change the value, does it save properly?

patent jewel
#

ok let me see

#

nope

#

try it did not work

white pollen
#

Hmm
I honestly have no idea

#

And you replaced the '500' with Player.Character.Hair.Value, right?

patent jewel
#

yes

#

@sonic portal you trying to help lol?

sonic portal
#

Give me a summary, @patent jewel

patent jewel
#

ok

#

so basically everything works execpt getting the number from the int value inside of the player, and it wont save

sturdy wyvernBOT
#

studio** You are now Level 7! **studio

sonic portal
patent jewel
#

how do I do that?

#

This is customzation so it will always shut down

sonic portal
#

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)
sturdy wyvernBOT
#

studio** You are now Level 42! **studio

sonic portal
#

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

patent jewel
#

ok i will try that

#

this what you mean

patent jewel
patent jewel
#

like this?

sonic portal
#

Correct 👍

#

This is not:

#

Try to fix your mistake

patent jewel
sonic portal
#

Now look back at where I told you to use WaitForChild

patent jewel
#

@sonic portal

patent jewel
patent jewel
#

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

patent jewel
sonic portal
# patent jewel

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

sonic portal
#

Store that information in the player

patent jewel
#

ok

#

how do I do that

#

Do I put Hair in players?

patent jewel
#

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

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

patent jewel
#

it is created inside the player @sonic portal

sonic portal
#

So how do you know that the data isn't loading?

patent jewel
#

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
patent jewel
#

yes