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.
wait(0.1)
local scr = script.Parent
local amount = math.random(10,100)
script.Parent.BillboardGui.TextLabel.Text = amount
if scr.Parent.Name == "Backpack" then
local player = scr.Parent.Parent
while player.Character == nil do
print ("NO CHARACTER")
wait(1)
end
print (player)
function onDied()
if player.Money.Value >= amount then
player.Money.Value = player.Money.Value - amount
local j = scr:Clone()
j.Position = player.Character.Torso.Position
j.Parent = game.Workspace
print("Money Dropped")
end
end
player.Character.Humanoid.Died:connect(onDied)
else
wait(1)
local enabled = true
function onTouch(part)
local p = game.Players:playerFromCharacter(part.Parent)
if p == nil then return end
if not enabled then return end
enabled = false
print("Money")
p.Money.Value = p.Money.Value + amount
wait()
scr:Remove()
end
scr.Touched:connect(onTouch)
end
