Help with false error in script!

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? For my script to work

  2. What is the issue? Error even though projected reason is false

  3. What solutions have you tried so far? Copying the leaderstats name in player to script and checked for typos

Hello! I have made a script but it does not seem to work due to a false error [It’s supposed to change UI Text depending on the leaderstats number value]

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGUI = game:GetService("StarterGui")
local workspace = game:GetService("Workspace")

local stageText = StarterGUI.stageUpdate.stage
local stages = workspace.Checkpoints:GetChildren()

stageText.Text = (game.Players.LocalPlayer.leaderstats.Stage.Value)

Photos

proof1

Can anyone help?

1 Like

Add a :WaitForChild() function.
The leaderstats folder doesn’t get added instantly.

local leaderstats = player:WaitForChild("leaderstats")
2 Likes

thanks!! ^w^ i’ll try that right now

1 Like

For some reason the text doesn’t update. It also doesn’t show the text when I run the game. I’ll try to find a tutorial for now but thank you!!

1 Like

You should probably either constantly update it or update it when the value changes. You are only changing it once and probably before the Stage value even changes from the leaderstats script.

You can use

Stage.Changed:Connect(function()
stageText.Text = (game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Stage").Value)
end)

or

game["Run Service"].RenderStepped:Connect(function()
stageText.Text = (game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Stage").Value)
end)
1 Like

oo yeah it changes the text value but for some reason the text still is invisible. I’m testing this in studio so idk if its only on studio haha, This has also happened on some tutorials i’ve followed

1 Like

I got it fixed by adding a PlayerGui line. Thanks a lot for your help :DD

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.