So I have made a leaderboard for wins and it works perfectly. However when you finish a minigame obby, you need to step on a part to win. I have tried using what I know such as
workspace.Button1.Touched:Connect(function() game.ServerScriptStorage.Leaderboard.Wins.Value + 1 -- the no. 1 will have to add to the value
can someone please tell me what I did wrong? I am a beginner scripter.
Okay so first thing, ServerScriptStorage isn’t meant to be a storage for anything else than server scripts/modules. However, in order to add 1 to your value, do this
The script above wouldn’t work because as I said, ServerScriptService isn’t meant to be holding values, try using ServerStorage instead; I just showed you the way of increasing a value.
Local scripts can’t access stuff on the server side
Scripts don’t run in ServerStorage. He was just suggesting that you moved the value.
I’ll break down why you have to write it twice. local Var = 0 – Your value Var = X – Set the new value to X Var = Var – Keep the value the same Var = Var + 1 – Add one to the old value (what you’re trying to do)
Var + 1 did not work work for two reasons. Firstly you’re not actually setting the value as you didn’t include =. Secondly, even if you did try to set the value, it’s effectivelyVar = nil + 1