-
What do you want to achieve? Keep it simple and clear!
I have a punching script and I want the player to not be able to punch when they have any tool equipped -
What is the issue? Include screenshots / videos if possible!
Anything I try doesn’t work. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried using values, which sometimes works, its unreliable though. ive tried just usingreturn end
when a tool is equipped, doesn’t work
this is my code, its messy im sorry
local OnCoolDown = false
local CoolDownTime = 0.3
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local TargetFound = false
local rs = game:GetService("ReplicatedStorage")
local hbEvent = rs.Events.hitbox2
local combo = 1
local h = plr.Character.Humanoid
local swing = script:WaitForChild("swing")
swing.Parent = plr.Character.HumanoidRootPart
local Punching = false
local uis = game:GetService("UserInputService")
if h:GetState() == Enum.HumanoidStateType.Jumping then
print("Jump")
end
Mouse.Button1Down:Connect(function()
local Can = game.ReplicatedStorage.AbleHit.Value
if OnCoolDown == false and Can == true then
Punching = true
h.JumpHeight = 0
h.JumpPower = 0
print(Can)
if combo == 1 then
print("1")
OnCoolDown = true
combo = 2
local track = h:LoadAnimation(script.Combo1)
track:Play()
swing:Play()
hbEvent:FireServer()
wait(CoolDownTime)
h.JumpHeight = 7.5
h.JumpPower = 50
Punching = false
OnCoolDown = false
return
end
if combo == 2 and Can == true then
print("2")
OnCoolDown = true
h.JumpHeight = 0
h.JumpPower = 0
combo = 3
local track = h:LoadAnimation(script.Combo2)
track:Play()
swing:Play()
hbEvent:FireServer()
wait(CoolDownTime)
h.JumpHeight = 7.5
h.JumpPower = 50
OnCoolDown = false
return
end
if combo == 3 and Can == true then
print("3")
OnCoolDown = true
h.JumpHeight = 0
h.JumpPower = 0
combo = 4
local track = h:LoadAnimation(script.Combo3)
track:Play()
swing:Play()
hbEvent:FireServer()
wait(CoolDownTime)
h.JumpHeight = 7.5
h.JumpPower = 50
OnCoolDown = false
return
end
if combo == 4 and Can == true and h:GetState() == Enum.HumanoidStateType.Freefall then
print("downslam")
OnCoolDown = true
h.JumpHeight = 0
h.JumpPower = 0
combo = 1
local track = h:LoadAnimation(script.Downslam)
track:Play()
swing:Play()
hbEvent.Parent.hitbox2Down:FireServer()
plr.Character.sprint.Enabled = false
wait(.01)
plr.Character.plrStun.Value = true
wait(.8)
h.JumpHeight = 7.5
h.JumpPower = 50
plr.Character.plrStun.Value = false
plr.Character.sprint.Enabled = true
OnCoolDown = false
return
end
if combo == 4 and Can == true then
local Heldspace = uis:IsKeyDown(Enum.KeyCode.E)
h.JumpHeight = 0
h.JumpPower = 0
if Heldspace == true then
combo = 1
local track = h:LoadAnimation(script.Uptilt)
track:Play()
swing:Play()
rs.Events.hitbox2Up:FireServer()
plr.Character.sprint.Enabled = false
wait(.01)
plr.Character.plrStun.Value = true
wait(1)
h.JumpHeight = 7.5
h.JumpPower = 50
plr.Character.plrStun.Value = false
plr.Character.sprint.Enabled = true
OnCoolDown = false
return
end
print("4")
OnCoolDown = true
combo = 1
local track = h:LoadAnimation(script.Combo4)
track:Play()
swing:Play()
hbEvent.hitbox2Last:FireServer()
plr.Character.sprint.Enabled = false
wait(.01)
plr.Character.plrStun.Value = true
wait(1.5)
h.JumpHeight = 7.5
h.JumpPower = 50
plr.Character.plrStun.Value = false
plr.Character.sprint.Enabled = true
OnCoolDown = false
return
end
end
end)
I want it to not do any of this stuff in the code when any tool is equipped, if thats possible