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

Drop cash on death math.random and billboardgui don't match up with each others values?

Asked by 9 years ago

Ok so what this does is drops a part named credit that players can pick up and I will provide a picture of the hierarchy (Explorer) and will also provide the script it uses math.random(10,100) to drop the cash but the billboardgui under the part don't show the correct amount that is in the credit part.

01wait(0.1)
02local scr = script.Parent
03local amount = math.random(10,100)
04script.Parent.BillboardGui.TextLabel.Text = amount
05 
06if scr.Parent.Name == "Backpack" then
07 
08 
09    local player = scr.Parent.Parent
10    while player.Character == nil do  
11    print ("NO CHARACTER")
12    wait(1)
13    end
14    print (player)
15 
View all 50 lines...

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago
01wait(0.1)
02local scr = script.Parent
03if scr.Parent.Name == "Backpack" then
04    local amount = math.random(10,100)
05    local player = scr.Parent.Parent
06        while player.Character == nil do  
07            print ("NO CHARACTER")
08            wait(1)
09        end
10    print (player)
11        function onDied()
12            if player.Money.Value >= amount then
13                player.Money.Value = player.Money.Value - amount
14                script.Parent.BillboardGui.TextLabel.Text = amount
15                local j = scr:Clone()
View all 36 lines...

I put both the if statement and the script.Parent.BillboardGui.TextLabel.Text = amount into the if statement. I've dealt with this kind of stuff before, and I remember it calling different numbers each function/if statement. Hopefully this works. I don't really have an explanation for why I did what I did, because in my mind, it works out perfectly, but I can't really put it into words.

Ad

Answer this question