I’m trying to make sure that the player can’t spam fire the bow and needs to draw the bow for 3 seconds before its ready to fire, but atm if I spam the mouse button enough and then hold down the button for half a second the “draw timer” increases at an insane rate and lets the player cheat the timer.
script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local drawtime = 0
local drawing = false
local canshoot = false
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
drawing = true
while drawing == true do
print(drawtime)
drawtime = drawtime + 1
wait(1)
if drawtime >= 3 then
canshoot = true
if drawtime < 3 then
canshoot = false
end
end
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
drawing = false
drawtime = 0
if canshoot then
script.Parent.Shoot:FireServer(mouse.Hit.p)
canshoot = false
drawing = false
drawtime = 0
end
end
end)
Could you not just put like a CD code in it or something where it is first false but then when the user clicks it changes to true and then put a wait for how long u want then false again if that makes sense.
That would the check to see if the user is still drawing or not.
I think I get what you mean but could you elaborate a little if possible? Do you mean like a single CD that lasts 3 seconds and then fires? Bc atm I’m trying to have a system where when you hold down the M1 button you draw the bow, and if you draw it for long enough (3 seconds atm) it will fire when you let go, otherwise, it will just undraw the bow and you will go back to idle.
Not sure if this would work (not exact of course but like the same idea).
local UIS = game:GetService("UserInputService")
local DrawTime = 3
local Drawed = false
UIS.InputBegan:Connect(function(input)
if Drawed == false then
Drawed = true
wait(DrawTime)
Drawed = false
else
-- Code for ddrawing.
end
end)
I’ll try this and just have the player click once to start the drawing process, and once the timer is done they can click again to shoot. I’ll let you know how it goes appreciate it
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local drawtime = 1
local drew = false
local canshoot = false
mouse.Button2Down:Connect(function()
if drew == false then
--play drawing animation while waiting
wait(drawtime)
drew = true
print("1@")
end
end)
mouse.Button1Down:Connect(function()
if drew == true then
print("2@")
script.Parent.Shoot:FireServer(mouse.Hit.p)
drew = false
end
end)