Two scripts, a money script and GUI cloning script, only working once? ggargagrgrgrae
The jist is that every time a player hit this block, one script increases a value in their leaderstats and the other clones and puts a GUI in their playergui (the gui just shows '+10', for the amnt gained)
However, it will only do this once. I am stumped. Why?
GUI cloning script:
05 | function getPlayer(humanoid) |
07 | local players = game.Players:children() |
11 | if players [ i ] .Character.Humanoid = = humanoid then return players [ i ] end |
25 | local human = part.Parent:findFirstChild( "Humanoid" ) |
27 | if (human ~ = nil ) and debounce = = false then |
35 | local player = getPlayer(human) |
39 | if (player = = nil ) then return end |
43 | user = game.Players:findFirstChild(human.Parent.Name) |
45 | local gui = script.Parent.Plus:clone() |
46 | gui.Parent = player.PlayerGui |
47 | gui.Frame.Amount.Find.Disabled = false |
70 | script.Parent.Touched:connect(onTouch) |
Cash adding script:
03 | function onTouched(part) |
05 | if debounce = = false then |
07 | local h = part.Parent:findFirstChild( "Humanoid" ) |
12 | local thisplr = game.Players:findFirstChild(h.Parent.Name) |
14 | if (thisplr~ = nil ) then |
16 | local stats = thisplr:findFirstChild( "leaderstats" ) |
22 | local cash = stats:findFirstChild( "SpeedCoin" ) |
26 | cash.Value = cash.Value+ 10 |
36 | script.Parent.Touched:connect(onTouched) |