So i have a weapon if you click with it, it takes the players stamina when the stamina is finished you wont be able to use the tool , but once your stamina finishes and then regens the tool stops working
local tool = script.Parent
local character
local equipAnim
local debounce = false
local tweenService = game:GetService("TweenService")
local tInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local t = tweenService:Create(script.Parent.Light, tInfo, {Color = Color3.fromRGB(248, 248, 248)})
local t2 = tweenService:Create(script.Parent.Light, tInfo, {Color = Color3.fromRGB(0, 0, 0)})
tool.Equipped:Connect(function()
if workspace.BloodHour.Value then
t2:Play()
tool.Light.SpotLight.Enabled = false
else
t:Play()
tool.Light.SpotLight.Enabled = true
end
character = tool.Parent
equipAnim = character.Humanoid:LoadAnimation(tool.Idle)
equipAnim:Play()
end)
tool.Unequipped:Connect(function()
equipAnim:Stop()
end)
tool.Activated:Connect(function()
if not debounce and character.stamina.Value >= 12.5 and not workspace.BloodHour.Value then
debounce = true
local swingAnim = character.Humanoid:LoadAnimation(tool.Swing)
swingAnim:Play()
local hitA = false
tool.Handle.Slash:Play()
local chance = math.random(1, 3)
local connection = tool.Handle.DamageBox.Touched:Connect(function(hit)
if hit.Name ~= "ObservationHitbox"then
if not hitA then
hitA = true
tool.Handle.Deflect.PlaybackSpeed = (1 + tonumber("0."..math.random(3, 6)))
tool.Handle.Deflect:Play()
if workspace:FindFirstChild("Rake") then
local headshot = 1
if hit:IsDescendantOf(workspace.Rake.Head) then
workspace.Rake.Headshot.Value = true
headshot = 2
end
if hit:IsDescendantOf(workspace.Rake) then
if workspace.Rake.Ragdoll.Value then
workspace.Rake.RagdollTime.Value += 1.5
else
if chance == 1 then
workspace.Rake.RagdollTime.Value += 0.75
else
workspace.Rake.RagdollTime.Value += 1.5
end
end
workspace.Rake.Monster:TakeDamage(math.random(4, 6) * headshot)
end
end
end
end
end)
wait(0.65)
connection:Disconnect()
wait(0.4)
debounce = false
end
end)
workspace.BloodHour.Changed:Connect(function()
if workspace.BloodHour.Value then
t2:Play()
tool.Light.SpotLight.Enabled = false
else
t:Play()
tool.Light.SpotLight.Enabled = true
end
end)