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

Two scripts, a money script and GUI cloning script, only working once? ggargagrgrgrae

Asked by 6 years ago

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:

01local debounce = false
02 
03 
04 
05function getPlayer(humanoid)
06 
07    local players = game.Players:children()
08 
09for i = 1, #players do
10 
11    if players[i].Character.Humanoid == humanoid then return players[i] end
12 
13end
14 
15    return nil
View all 70 lines...

Cash adding script:

01debounce = false
02 
03function onTouched(part)
04 
05    if debounce == false then
06 
07    local h = part.Parent:findFirstChild("Humanoid")
08 
09 
10    if (h~=nil) then
11 
12        local thisplr = game.Players:findFirstChild(h.Parent.Name)
13 
14        if (thisplr~=nil) then
15 
View all 36 lines...
0
The title spam was because it would not let me post my question, saying it was not concise enough. Sorry Octocentillion 15 — 6y
0
It only adds cash once, or only shows the GUI once? DinozCreates 1070 — 6y
0
ggargagrgrgrae greatneil80 2647 — 6y
0
Both, Dinoz. Octocentillion 15 — 6y
View all comments (3 more)
0
Are they both server scripts? Why are they in seperate scripts? DinozCreates 1070 — 6y
0
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 Octocentillion 15 — 6y
0
Merge them, clean up the indentation, get rid of all the useless whitspace. DinozCreates 1070 — 6y

1 answer

Log in to vote
0
Answered by
sydre2 25
6 years ago

The problem is that you included the debounce = false before the end. In this case, if (human ~= nil) and debounce == false then the debounce = false will not run because you've put it after the else statement. To make the script work, you just need to move the debounce = false under one end statement and it will set debounce to false even if (human ~= nil) and debounce == false

Ad

Answer this question