Help, It won’t work to set my value in Leaderstats
Alright?? Show the script, please!
Script:
-- Services
local Players = game:GetService("Players");
local ReplicatedStorage = game:GetService("ReplicatedStorage");
-- Main Variables
local ValueFolder = ReplicatedStorage:WaitForChild("Values")
Players.PlayerAdded:Connect(function(Player)
-- Instance Variables
local PlayerData = Instance.new("NumberValue")
local Leaderstats = Instance.new("Folder")
local Score = Instance.new("IntValue")
-- Player Data
PlayerData.Name = Player.Name
PlayerData.Parent = ValueFolder
-- Leaderstats
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player
-- Score
Score.Name = "Score"
Score.Parent = Leaderstats
-- Handler
local function update()
Score.Value = game.ReplicatedStorage.Values:WaitForChild(Player.Name).Value
end
update()
end)
Errors:
N/A
ReplicatedStorage:
ServerScriptService:
Leaderstats:
Problem:
I’ve created a lag test game and am working on a maximum score, however the problem is that it won’t alter the Value when it should. The value is spawned based on the folder in ReplicatedStorage, so when you spawn in, for example, the value will look like this:
How it works:
When you hit the button, it will perform the following actions:
As you can see, I added a block for the arrow at step 5, which is because it ignores the value and returns to 1. Except for step 5, everything else works. Let’s go ahead and press the button!
Pressed Button_
As you can see, it behaves exactly as I predicted, returning no value in the leaderboard.
Output:
So you don’t have to ask, here’s the result. The warning that it could not locate MaxScore has nothing to do with my scripts, as I know that I neglected to MaxScore in a alter script. That is something I am absolutely certain of.
It would be great if you could provide an appropriate solution.