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:
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
user = game.Players:findFirstChild(human.Parent.Name)
local gui= script.Parent.Plus:clone()
gui.Parent = player.PlayerGui
gui.Frame.Amount.Find.Disabled = false
wait(2)
else
wait(2)
debounce = false
end
end
script.Parent.Touched:connect(onTouch)
Cash adding script:
debounce = false
function onTouched(part)
if debounce == false then
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
debounce = true
local cash = stats:findFirstChild("SpeedCoin")
if (cash~=nil) then
cash.Value = cash.Value+ 10
wait(0.3)
debounce = false
end
end
end
end
end
end
script.Parent.Touched:connect(onTouched)

7 comments
The title spam was because it would not let me post my question, saying it was not concise enough. Sorry
It only adds cash once, or only shows the GUI once?
ggargagrgrgrae
Both, Dinoz.
Are they both server scripts? Why are they in seperate scripts?
they are both server scripts. and idk, i just never thought to combine them. never had a problem with the separately till i put them in the same brick
Merge them, clean up the indentation, get rid of all the useless whitspace.