It runs, but twice?
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?
03 | cola = script.Parent.b 1. Handle |
04 | colascript = script.Parent.b 1. ApertureColaScript |
09 | cola.CFrame = CFrame.new( 6.765 , cola.Position.Y + 0.01 , 8.622 ) |
14 | function onCola (player) |
15 | if dispensing = = false then |
16 | if not player.Backpack:FindFirstChild( "Aperture Cola" ) then |
20 | cola.CFrame = CFrame.new( 6.765 , 3 , 8.622 ) |
21 | local colanew = cola:Clone() |
22 | local colatool = Instance.new( "Tool" ,player.Backpack) |
23 | local scriptnew = colascript:Clone() |
24 | colatool.Name = "Aperture Cola" |
25 | scriptnew.Parent = colatool |
26 | colanew.Parent = colatool |
27 | colanew.Transparency = 0 |
34 | cola 2 = script.Parent.b 2. Handle |
35 | colascript 2 = script.Parent.b 2. RepulsionSodaScript |
38 | cola 2. Transparency = 0 |
40 | cola 2. CFrame = CFrame.new( 6.765 , cola 2. Position.Y + 0.01 , 8.622 ) |
45 | function onCola 2 (player) |
46 | if dispensing = = false then |
47 | if not player.Backpack:FindFirstChild( "Repulsion Soda" ) then |
50 | cola 2. Transparency = 1 |
51 | cola 2. CFrame = CFrame.new( 6.765 , 3 , 8.622 ) |
52 | local colanew = cola 2 :Clone() |
53 | local colatool = Instance.new( "Tool" ,player.Backpack) |
54 | local scriptnew = colascript 2 :Clone() |
55 | colatool.Name = "Repulsion Soda" |
56 | scriptnew.Parent = colatool |
57 | colanew.Parent = colatool |
58 | colanew.Transparency = 0 |
65 | script.Parent.b 2. b 2. ClickDetector.MouseClick:connect(onCola 2 ) |
66 | script.Parent.b 1. b 1. ClickDetector.MouseClick:connect(onCola) |