#Player Prefs Not Working

1 messages · Page 1 of 1 (latest)

finite sluice
#

Use interpunctuation, dammit. What you are saying/asking is really hard to interpret, if you literally talk without commas and periods.

That being said, you haven't told us what issue you are actually facing.
"Not working" is not enough of an error description to go by. And aside from that, all the information you have given amounts to that you have save and load methods, that you are setting a value to "20" at the start of the game's first scene, that you are not calling your save method, and that you are trying to make a currency [system].

You have not clarified what you expect to happen, nor what is actually happening.

Beyond that, I think you got "method" and "class" confused. Having entire classes for saving and loading seems a little redundant after all.
And generally, PlayerPrefs - as the name suggests - are for storing preferences. They are not meant to hold game data, like a player's current money, score, or anything along those lines.

abstract smelt
#

Sorry for all the mistakes. the goal is that i dont want it to start at 20. you said not to use playerprefs than what should i use

finite sluice
#

Some other method of saving. Preferably one that writes to an actual save file (and not to the registry like PlayerPrefs do).

#

And if you don't want to start at 20, just don't set the value to 20 at the start?

abstract smelt
#

i dont set the value to 20 thats why im lost

finite sluice
#

Well, PlayerPrefs won't have a value by default. You probably did set the value at some point, and it stored that.
Just delete the pref key or reset the value and you should be good.

abstract smelt
#

when do i delete or how do i reset im new sorry

river crane
abstract smelt
#

I will try but i did for like an hour already but i will try again

mortal elk
abstract smelt
#

so you can learn on your own because im new im assuming

mortal elk
abstract smelt
#

ok

river crane
# mortal elk this is bad advice why would you trial and error

That makes sense, I guess I associated with solving other problems. I find that when I aimlessly watch tutorials or look up answers, I don't understand half of what I am doing. So I try my best to think of solutions first. But you have mentioned that syntax is incredibly specific so I understand where you are coming from. Sorry for answering foolishly, I will make sure to avoid answering questions I am not confident about in the future. Thank you for letting me grow 😄

finite sluice
#

I would argue that sometimes, you do have to try stuff; there isn't a tutorial for every specific situation you may find yourself in, so trial-and-error can be useful.

However knowing your tools (e.g. the methods provided by the framework/engine/...) is essential for being able to properly conduct trial-and-error.
In that sense, documentation should usually be the first thing to look up, if you find that you don't know how to do something.

abstract smelt
#

your not entirely wrong i keep seeing videos about your not learning anything by wacthing tutorials and i think that doing it yourself is the best way to do it

mortal elk
#

yeah i do agree that trial and error can be beneficial for learning. but not in the case of syntax, like finding a function name

abstract smelt
#

so i put PlayerPrefs.DeletKey() at the start. it made the automatically setting it to 20 part fix but it just keeps it deleted. I need to put deletkey once but how would i do that.

#

sorry you have to donload the video dont know how to add it as not download.

finite sluice
#

You need to upload it in a format that discord can embed. Like .mp4

abstract smelt
#

ok

#

one sec

#

there ya go

finite sluice
#

Well, deleting the key serves to reset the state.
If you only need to save the value between scenes, you shouldn't be saving it to the hard drive at all. PlayerPrefs are even less for making state transition than they are for saving state.

abstract smelt
#

then what should i use

abstract smelt
#

Z...

finite sluice
#

For transitioning state between scenes, you mean?

#

You could use a static variable. You could use a singleton that's dontdestroyonload. You could use a scriptable object instance.

abstract smelt
#

do you have somthing i can serch on youtube for