The debounce doesn’t seem to be working for this, if I spam button1down the text will go between loading and ready
i’ve tried switching to other things and tryna figure out solutions but nothing works
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local cam = workspace.CurrentCamera
local SniperGui = plr.PlayerGui:WaitForChild("SniperGui")
local uis = game:GetService("UserInputService")
local remotes = game.ReplicatedStorage.Remotes
local shot = false
SniperGui.Enabled = true
-- // Variables
local mouse = plr:GetMouse()
local equipped = false
mouse.TargetFilter = workspace.Barriers
mouse.Button1Down:Connect(function()
if equipped and not uis.TouchEnabled then
if not shot then shot = true end
local lv = cam.CFrame.LookVector
remotes.Round.Shoot:FireServer(lv, script.Parent.Nuzzle)
SniperGui.Reloading.Text = "Reloading"
task.wait(1)
SniperGui.Reloading.Text = "Ready!"
shot = false
wait(0.3)
end
end)
script.Parent.Equipped:Connect(function()
equipped = true
end)
script.Parent.Unequipped:Connect(function()
equipped = false
end)
if not shot then shot = true end
-- even if shot is false, this still gets executed because it's not part for the actual if statement
you can fix this by wrapping the entire script in the if function.
mouse.Button1Down:Connect(function()
if equipped and not uis.TouchEnabled then
if not shot then
shot = true
local lv = cam.CFrame.LookVector
remotes.Round.Shoot:FireServer(lv, script.Parent.Nuzzle)
SniperGui.Reloading.Text = "Reloading"
task.wait(1)
SniperGui.Reloading.Text = "Ready!"
shot = false
wait(0.3)
end
end
end)
I dont use not so I’m not sure, but couldnt you just wrap the entire script in if shot == false then, it kind of looks like you’re just setting the debounce to true if its false then running the rest of the script regardless of whether its true or not.