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

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

Asked by 4 years ago
Edited 4 years 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

1    if workspace:FindFirstChild(Player.Name.." Stand") then
2        if debounce == false then
3            debounce = true
4 
5            Barrage:FireServer()
6        end
7    end
8 
9end

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

1    if workspace:FindFirstChild(Player.Name.." Stand") then
2        if debounce == false and active == false then
3            debounce = true
4 
5            Barrage:FireServer(active)
6        end
7    end
8 
9end

end)

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

1    if workspace:FindFirstChild(Player.Name.." Stand") then
2        if debounce == true and active == false then
3            active = true
4 
5            Barrage:FireServer(active)
6        end
7    end
8 
9end

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 50 — 4y

1 answer

Log in to vote
0
Answered by 4 years 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