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

My bindable event fires once, but the other script gets it twice. Why does this happen?

Asked by 4 years ago

The firing stage

PhoneFriend.ButtonClicked.OnServerEvent:Connect(function(Player,ButtonName)
    print("ButtonClicked.OnServerEvent:Connect")    
    print(ButtonName)
    local PlayerName = ButtonName
    PhoneFriend.PlayerName.Value = PlayerName
    Players = game:GetService("Players"):GetPlayers()
    for i,plr in pairs(Players) do
        if plr.Character.HumanoidRootPart then
            if plr.Name == PlayerName then
               print("This is the player!")
               character = plr.Character
               if character then
                  -- Teleport Them
                  character:FindFirstChild("HumanoidRootPart").CFrame = PhoneFriendSpawn.CFrame + Vector3.new(0,10,0)
--                local MasterControl = require(plr:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
--                MasterControl:Disable()
                  wait(0.5)
                  character:FindFirstChild("HumanoidRootPart").Anchored = true
            end
        end
    end
  end             
  if StartTimerPressed == 0 then
     StartTimerPressed = 1        
     print("PhoneFriend.StartTimer:Fire()")
     PhoneFriend.StartTimer:Fire()
  end 
  PhoneFriend.PhoneFriendNotVisible:FireClient(Player)
  print("This is not the player!")
end)

And the script connecting it.

PhoneFriend.StartTimer.Event:Connect(function()
 if debounce == 0 then
    debounce = 1    
    NumberGUI.Visible = true
    print("Timer Started")
    while Timer.Value >= 0 do       
        print("Timer before deduction is"..Timer.Value)  
        Timer.Value = Timer.Value - 1
        print(Timer.Value)
        print("Timer after deduction is"..Timer.Value)
        TimerText = tostring(Timer.Value)
        NumberGUI.Text = TimerText
        local Contestants = game:GetService("Players"):GetChildren()
        PhoneFriend:WaitForChild("ChangeTimer"):FireAllClients(Timer.Value)             
        wait(1)                 
      end
    end
    NumberGUI.Visible = false
    PhoneFriend.EndTimer:Fire()
    print("End of Timer")
end)    

Answer this question