I was working on a Gui which contains a player's statistics for a sword fighting game. However, it only works in play solo, but not on a test server. I think it is because of a "Works in Studio, but not online effect" :(
Here are the errors in the test server: 12:02:54.479 - Credits is not a valid member of TextLabel 12:02:54.479 - Script 'Players.Player1.PlayerGui.StatGui.StatFrame.Credits.TextLabel.LocalScript', Line 1 12:02:54.480 - Stack End 12:02:54.480 - Wins is not a valid member of TextLabel 12:02:54.480 - Script 'Players.Player1.PlayerGui.StatGui.StatFrame.Wins.TextLabel.LocalScript', Line 3 12:02:54.481 - Stack End 12:02:54.481 - Level is not a valid member of TextLabel 12:02:54.481 - Script 'Players.Player1.PlayerGui.StatGui.StatFrame.EXP.Level.LocalScript', Line 1 12:02:54.482 - Stack End 12:02:54.482 - EXP is not a valid member of TextLabel 12:02:54.482 - Script 'Players.Player1.PlayerGui.StatGui.StatFrame.EXP.EXP.LocalScript', Line 2 12:02:54.483 - Stack End
Here are the scripts: (P.S. All of them are local scripts!)
Credits
script.Parent.Text = script.Parent.Credits.Value
script.Parent.Credits.Changed:connect(function()
script.Parent.Text = script.Parent.Credits.Value
end)
Wins
script.Parent.Text = script.Parent.Wins.Value
script.Parent.Wins.Changed:connect(function()
script.Parent.Text = script.Parent.Wins.Value
end)
EXP
local Player = game.Players.LocalPlayer
local EXP = script.Parent.EXP
local level = script.Parent.Parent.Level.Level
local target = script.Parent.Target
script.Parent.Text = EXP.Value..' / '..target.Value
EXP.Changed:connect(function()
script.Parent.Text = EXP.Value
if EXP.Value >= target.Value then
level.Value = level.Value + 1
EXP.Value = EXP.Value - target.Value
target.Value = 100*level.Value + 10*(level.Value-1)
repeat until EXP.Value < target.Value
end
script.Parent.Text = EXP.Value..' / '..target.Value
end)
Level
local level = script.Parent.Level
script.Parent.Text = 'Lv. '..level.Value
level.Changed:connect(function()
script.Parent.Text = 'Lv. '..level.Value
end)
How should I change the scripts to make them Work in BOTH Studio and Online?

4 comments
I know this is long, but pls help me with this!
You're probably trying to reference objects that aren't there yet. Try using WaitForChild.
https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online
Well! Thanks, LightningRoMan! The problem is solved! Next time, try answering it by making an example on one of the scripts instead of commenting, so I can accept your answer and we can get reputation points! :D