The script's parent should display the player's coin value, but it isn't working. The final product should say 500000 MC (I set the value in the StarterPack to 500000).
a = script.Parent.Parent.Parent.Parent.Parent.Parent.StarterPack.Coins.Value script.Parent.Text = a.."MC"
Pretty sure you just made small errors. Try this script. If it doesn't work, don't thumbs down. Tell me the error and see if I can fix it.
Note: Make sure to use a localscript for this. "game.Players.LocalPlayer" is only accessible through one.
while wait(10) do --loops this code every 10 seconds local player = game.Players.LocalPlayer --use this instead of what you had before, if the hierarchy gets messed up it will break . local coins = player.StarterGear:WaitForChild("Coins") --waits for "Coins", located in the player's startergear. script.Parent.Text = coins.Value .. "MC" --displays text on the gui. end
1. Don't set properties as variables, but the objects:
a = script.Parent.Parent.Parent.Parent.Parent.Parent.StarterPack.Coins script.Parent.Text = a.Value.."MC"
2. Use changed
event and not a while true
loop to update the value, it will eat less resources:
a = script.Parent.Parent.Parent.Parent.Parent.Parent.StarterPack.Coins a.Changed:connect(function() script.Parent.Text = a.Value.."MC" end)
3. Using local on variables eat less resources:
local a = script.Parent.Parent.Parent.Parent.Parent.Parent.StarterPack.Coins a.Changed:connect(function() script.Parent.Text = a.Value.."MC" end)
4. Why starterpack? On ServerScriptService, insert a script, which contains the code:
game.Players.PlayerAdded:connect(function(player) local val = Instance.new("IntValue") val.Name = "Coins" val.Parent = player val.Value = 500000 player.PlayerGui.ScreenGui.fefe.fefhtuy.ggrgd.af.Text = val.Value.."MC" -- change the hierarchy by yourself val.Changed:connect(function() player.PlayerGui.ScreenGui.fefe.fefhtuy.ggrgd.af.Text = val.Value.."MC" -- change the hierarchy by yourself end) end)