Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Coins GUI not working?

Asked by 10 years ago

I want the GUI to display the players coins. I have tryed this and it dosent want to work?? Aneyone got a solution

Leaderboard:

game.Players.PlayerAdded:connect(function(player)

    stats = Instance.new ("IntValue", player)
    stats.Name = "leaderstats"

    coins = Instance.new ("IntValue", stats)
    coins.Name = "Coins"
    coins.Value = 10

end)

game.Players.PlayerRemoving:connect(function(player)

end)

GUI script:

while true do
    if script.Parent.Text == "0" then
    script.Parent.Text = game.Players.leaderstats.Coins.Value
    end
end

4 answers

Log in to vote
0
Answered by
Andalf 100
10 years ago

Gui Script

local player = game.Players.LocalPlayer
script.Parent.Text = player.leaderstats.Coins.Value -- added this line to initialise the gui.

player.leaderstats.Coins.Changed:connect(function()
    script.Parent.Text = player.leaderstats.Coins.Value
end) -- Wrapping your function like this ensure it only changes when the value changes, this is better than a while loop and is called an anonymous function. 

I've defined player as a local value to match the games local player, this has to be in a localscript to work, localscripts should work fine inside of the players character, the current camera, the players backpack or the players gui.

0
do i use localscript or script?? NinjoOnline 1146 — 10y
0
LocalScript Andalf 100 — 10y
0
ok, thansk, but idnt the same as the last answer NinjoOnline 1146 — 10y
0
nope, the game loads, but.. it the gui still says 0, not 10 NinjoOnline 1146 — 10y
View all comments (10 more)
0
I changed the script, as you had the Coins with a lowercase c and value with a lowercase V. I believe they should of been capatalized. Correct me if im wrong NinjoOnline 1146 — 10y
0
I was wrong, I just corrected that for you, sorry :). Andalf 100 — 10y
0
what should be the Parent of the LocalScript. Currently I have it in the TextBox NinjoOnline 1146 — 10y
0
TextBox is fine Andalf 100 — 10y
0
It still dosent work?? Can you try in a Single Player wolrd too? NinjoOnline 1146 — 10y
0
maybe it has something to do with leaderboard? NinjoOnline 1146 — 10y
0
okay, fixed it, should work fine now. Tested it for you too, I had no problems. Andalf 100 — 10y
0
OMG, thank you soo much. Works :D NinjoOnline 1146 — 10y
0
Hey do you think you could help me with a few scripts to my game?? willing to work out a cost or something??? NinjoOnline 1146 — 10y
0
Hey, I need the script to now look at your teams kills, like in a round with blue vs red and I need it so blues GUI displays all of blues team kills put together, how could I edit for that reason? NinjoOnline 1146 — 10y
Ad
Log in to vote
0
Answered by
war8989 35
10 years ago

In your GUI Script, on line 3, you aren't pointing to a player which is why it's not working. Make sure the GUI script is in a LocalScript and change line 3 to look like this: script.Parent.Text = game.Players.LocalPlayer.leaderstats.Coins.Value. I hope this helps!

0
Where should the local script be?? In the starter GUi, the screen gui, the text box?? NinjoOnline 1146 — 10y
0
It just makes my character not even load now. When I click pla it just says Waiting for character for 5 minutes NinjoOnline 1146 — 10y
0
The LocalScript should be a child of the TextBox. war8989 35 — 10y
0
It still just says Waiting for Character?? IS it just my internet?? NinjoOnline 1146 — 10y
View all comments (7 more)
0
Yes, you should either reconnect to your router/modem, restart your computer, or restart your router/modem and try it again. war8989 35 — 10y
0
ok NinjoOnline 1146 — 10y
0
Ok, it still didnt work. It has the 10 coins in the leaderboard, but 0 in the gui NinjoOnline 1146 — 10y
0
Nope nothing. I have restarted comp and router. It has to be the local script, cause when I removed it it worked. Is their a way to do it without localscript??? NinjoOnline 1146 — 10y
0
Copy and Paste what is inside the LocalScript here so I can look at it. war8989 35 — 10y
0
while true do if script.Parent.Text == "0" then script.Parent.Text = game.Players.LocalPlayer.leaderstats.Coins.Value end end NinjoOnline 1146 — 10y
0
NinjoOnline, try this: while true do script.Parent.Text = game.Players.LocalPlayer.leaderstats.Coins.Value end war8989 35 — 10y
Log in to vote
-1
Answered by 10 years ago

It should.

Log in to vote
-1
Answered by
Asleum 135
10 years ago

Make sure that you're testing this script online, as most leaderboard scripts don't work in solo mode. Also, don't forget to add a wait() just before the end in your while loop, if you don't it will cause your computer to run out of memory. Anyways, if it still doesn't work, is there anything in the output ?

0
Still not working. I have put it on a place. The leaderboard loads up, just not the GUI dosent work NinjoOnline 1146 — 10y

Answer this question