Ad
Log in to vote
0

How do i make 'F' do something and fixinfinite yield?

Asked by 1 year ago
Edited 1 year ago

~~~~~~~~~~~~~~~~~ local Player = game:GetService("Players").LocalPlayer

local rp = game:GetService("ReplicatedStorage") local Barrage = rp:WaitForChild("BarragePress")

local UIS = game:GetService("UserInputService")

local debounce = false local cooldown = 3

UIS.InputBegan:Connect(function(input,IsTyping) if IsTyping then return elseif input.KeyCode == Enum.KeyCode.F then

    if workspace:FindFirstChild(Player.Name.." Stand") then
        if debounce == false then
            debounce = true

            Barrage:FireServer()
        end
    end

end

end)

Barrage.OnClientEvent:Connect(function() wait(cooldown) debounce = false end)

local Player = game:GetService("Players").LocalPlayer

local rp = game:GetService("ReplicatedStorage") local Barrage = rp:WaitForChild("BarrageHold")

local UIS = game:GetService("UserInputService")

local debounce = false local active = false local cooldown = 3

UIS.InputBegan:Connect(function(input,IsTyping) if IsTyping then return elseif input.KeyCode == Enum.KeyCode.F then

    if workspace:FindFirstChild(Player.Name.." Stand") then
        if debounce == false and active == false then
            debounce = true

            Barrage:FireServer(active)
        end
    end

end

end)

UIS.InputEnded:Connect(function(input,IsTyping) if IsTyping then return elseif input.KeyCode == Enum.KeyCode.F then

    if workspace:FindFirstChild(Player.Name.." Stand") then
        if debounce == true and active == false then
            active = true

            Barrage:FireServer(active)
        end
    end

end

end)

Barrage.OnClientEvent:Connect(function() wait(cooldown) active = false debounce = false end) ~~~~~~~~~~~~~ whenever i press F i get a error message is there something i did wrong?

ERROR:Infinite yield possible on 'ReplicatedStorage:WaitForChild("BarragePress")'

0
the error is under line 2 Not_prototype 26 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

Infinite yield just means that the script is paused. Probably because it couldn't find your BarragePress, so it just waited forever for it to exist. Make sure BaragePress is an actual thing in the ReplicatedStorage.

Ad

Answer this question