My debounce not work? Work only my first function
Asked by
5 years ago Edited 5 years ago
Hi guys, sorry for bad english.
This script work only the first time, after stop working, like an infinite Debounce
This is only a little part of my script. Work only the first function (?Maybe because i use the same debounce?) Is better if i use the _G. debounce?
01 | local Phere 2 = workspace.StartPhere [ 'Complimenti!' ] :WaitForChild( "2" ) |
02 | local Phere 3 = workspace.StartPhere [ 'Complimenti!' ] :WaitForChild( "3" ) |
03 | local Phere 4 = workspace.StartPhere [ 'Complimenti!' ] :WaitForChild( "4" ) |
07 | local function OnTouch 2 () |
10 | if player.leaderstats.PhereStage.Value = = 1 then |
11 | ShowMessage:Fire( "Complimenti! Hai superato la fase 1 della Obby di Phere!" , true ) |
18 | Phere 2. Touched:Connect(OnTouch 2 ) |
20 | local function OnTouch 3 () |
23 | if player.leaderstats.PhereStage.Value = = 2 then |
24 | ShowMessage:Fire( "Complimenti! Hai superato la fase 2 della Obby di Phere!" , true ) |
31 | Phere 3. Touched:Connect(OnTouch 3 ) |
33 | local function OnTouch 4 () |
36 | if player.leaderstats.PhereStage.Value = = 3 then |
37 | ShowMessage:Fire( "Complimenti! Hai superato la fase 3 della Obby di Phere!" , true ) |
44 | Phere 4. Touched:Connect(OnTouch 4 ) |
EDIT:
"You not change the PhereStage.Value, for this not work!"
ERROR, i change it with a script inside the Object
01 | function Pherestage(hit) |
02 | if hit.Parent ~ = nil then |
03 | local player = game.Players:playerFromCharacter(hit.Parent) |
05 | if player.leaderstats.PhereStage.Value = = script.Parent.Name - 1 then |
06 | local plr = hit.Parent:FindFirstChild( "Humanoid" ) |
09 | player.leaderstats.PhereStage.Value = script.Parent.Name |
17 | script.Parent.Touched:connect(Pherestage) |