New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

hi I search some help please to fix My screen gui ?

Asked by 10 days ago

Hi I've tryed to do a gui who it will show the money that we will earn (4 guy in game and it will show it like a global leaderboard but only for the money) but i don't know how to do it I try to do something but It won't work....

here is the script:

local Players = game:GetService("Players")
game.Players.ChildAdded:connect(function(player)
local indicateur = math.random(1,4)

if indicateur == 1 then
script.Parent.Indicator1.Text = " "..Players:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end

if indicateur == 2 then
script.Parent.Indicator2.Text = " "..Players:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end

if indicateur == 3 then
script.Parent.Indicator3.Text = " "..Players:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end

if indicateur == 4 then
script.Parent.Indicator4.Text = " "..Players:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end

end)

any Idea to fix it ?

2 answers

Log in to vote
0
Answered by
Nowaha 425 Moderation Voter
10 days ago
Edited 8 days ago

You are currently trying to get leaderstats inside of the Players array, but you're probably trying to get it inside of the player.

You can also use the elseif ... then statement instead of all the seperate if statements to increase performance, because it will now check them all, but if you use else if it will only check if the previous one was not true.

local Players = game:GetService("Players")

Players.ChildAdded:Connect(function(player)
    local indicateur = math.random(1,4)

    if indicateur == 1 then
        script.Parent.Indicator1.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
    elseif indicateur == 2 then
        script.Parent.Indicator2.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
    elseif indicateur == 3 then
        script.Parent.Indicator3.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
    elseif indicateur == 4 then
        script.Parent.Indicator4.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
    end
end)
0
I got an error at the last end at line 14 of your script I don't know why inconue88 0 — 8d
0
Sorry, fixed it now! I used "else if" because I'm used to different languages, but it's supposed to be together; "elseif". Nowaha 425 — 8d
Ad
Log in to vote
0
Answered by 7 days ago

To Nowaha :ok so it's didnt show error but it's stil don't work so, in this script, I want to do a thing, it's if the n°1 is taked so take another one but I don't know how to do please could you write me what did i need to do ? here is the script:

local player = game.Players.LocalPlayer
local indicateur = math.random(1,4)

if indicateur == 1 then
script.Parent.Indicator1.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end

if indicateur == 2 then
script.Parent.Indicator2.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end

if indicateur == 3 then
script.Parent.Indicator3.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end

if indicateur == 4 then
script.Parent.Indicator4.Text = " "..player:WaitForChild("leaderstats"):FindFirstChild("Argent").Value
end
0
What does not work exactly? Do none of the indicators show text? Nowaha 425 — 7d
0
the things that not work is the checking system I do to the script do is for 1 player that come to the game it have 1 indicators and if there a 2 player it have a indicators too but not the same indicator inconue88 0 — 6d

Answer this question