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

Debounce certain parts of code?

Asked by 4 years ago

Hey all, I am currently having troubles with debounce. I am attempting to Debounce the first half of my code until the second half is complete. However when I attempt to do this, the code is debounced but the second half doesn't play out. Any reasons why?

01local UIS = game:GetService("UserInputService")
02local rp = game.ReplicatedStorage
03local debounce = false
04local unsummon = false
05UIS.InputBegan:Connect(function(input,isTyping)
06        if isTyping then
07            return
08        elseif input.KeyCode == Enum.KeyCode.Q then
09            if not debounce then
10            rp.DefStand.Summon:FireServer()
11            debounce = true
12            wait(3)
13            debounce = false
14            end
15UIS.InputBegan:Connect(function(input,isTyping)
View all 23 lines...

Server script

01game:GetService("ReplicatedStorage").DefStand.Summon.OnServerEvent:Connect(function(player)
02    local sound = workspace.DS_summon
03    local Stand = game:GetService("ServerStorage").DefaultStand:Clone()
04    local StandModel = Stand.Dummy:Clone()
05    local debounce = false
06 
07    sound:Play()
08    StandModel.Parent = workspace
09    if StandModel then
10        local function summonWeld()
11            local char = player.Character or player.CharacterAdded:Wait() --Error here.
12            local weld = Instance.new("WeldConstraint")
13 
14            weld.Parent = game.Workspace
15            weld.Part0 = char.HumanoidRootPart
View all 28 lines...

Answer this question