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

It runs, but twice?

Asked by
sigve10 94
9 years ago

I have made a script for a soda dispenser, but for some strange reason: when the button is clicked, it runs the onCola2 twice!?

Is this because of something in the name, as the other onCola is perfectly fine and does not run more than once when the button is pressed. I copied the onCola2 script from the onCola script, and changed the name, as they are in the same script to avoid spending way too much time making connections between many scripts (dispense boolean). Anyone who can help me?

01dispensing = false
02 
03cola = script.Parent.b1.Handle
04colascript = script.Parent.b1.ApertureColaScript
05function makecola()
06    dispensing = true
07    cola.Transparency = 0
08    for i=150,300 do
09        cola.CFrame = CFrame.new(6.765, cola.Position.Y + 0.01, 8.622)
10        wait()
11    end
12end
13 
14function onCola (player)
15    if dispensing == false then
View all 66 lines...
0
you put "if dispensing == false then lucas4114 607 — 9y
0
but didn't put dispensing = true after it lucas4114 607 — 9y
0
I have it above in the function makecola2 sigve10 94 — 9y

1 answer

Log in to vote
0
Answered by
sigve10 94
9 years ago

NVM I fixed it. Remember me saying: I put it all in one script to avoid making connections between scripts? Well, I had forgotten to take away the earlier script. But I guess this answered the question anyways.

Ad

Answer this question