Spam throwing issue

Hey, I’m making a throwing table gear and it works fine until a player spam clicks.

This is an example of what happens:

https://gyazo.com/5ad43653cd88e3840f869187a5d5be7f.gif

What have I done wrong?

Server Script
local LastActivated  = tick()

local DB = false

Tool.Activated:Connect(function()
	if tick() - LastActivated >= 5 then
		if DB == true then 
			return 
		end
		DB = true
		local Tool = script.Parent
		local Character = Tool.Parent
		local Hum = Character.Humanoid
		local Target = Hum.TargetPoint 
		local Look = Character.HumanoidRootPart.CFrame.lookVector
		local Throw = script.Parent.Handle:Clone()
		Throw.CanCollide = true 
		Throw.Size = Vector3.new(1.95, 1.95, 1.95)
	
		Throw.Parent = workspace.Game.Debris
		Throw.Velocity = Look * 150
		
		local Damage = true
		
		DB = false
	
		Throw.Touched:Connect(function(Hit)
			
		if Damage == true then
			
		if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent:FindFirstChild("Humanoid") ~= Hum and Damage == true then
			Damage = false
			Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(math.random(5, 15))
			wait(1)
		end
	end
end)
	
	local Force = Instance.new("BodyForce") 
	Force.force = Vector3.new(0, 5, 0) 
	Force.Parent = Throw
	script.Parent.Handle.Transparency = 1
	wait(1)
	DB = false
	script.Parent.Handle.Transparency = 0
	end
end)
Local Script
script.Parent.Equipped:Connect(function(Equip)
	wait(0.1)
	script.Parent.Events.RE1:FireServer()
end)

local ActivateLock = false
local OldFace = game.Players.LocalPlayer.Character.Head.face.Texture

script.Parent.Activated:Connect(function()
	if ActivateLock == false then
		ActivateLock = true
		script.Parent.Events.RE2:FireServer()
		game.Players.LocalPlayer.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=152630087"
		wait(2.5)
		ActivateLock = false
		game.Players.LocalPlayer.Character.Head.face.Texture = OldFace
	end
end)

script.Parent.Unequipped:Connect(function()
	wait(0.3)
	pcall(function()
	game.Players.LocalPlayer.Backpack.Table.Parent = game.Players.LocalPlayer.Character
	end)
end)
1 Like

I don’t see you setting LastActivated anywhere?

Sorry forgot to add that, check again.

You need to give this a new value as soon as you ‘trigger’ the gear.

LastActivated = tick()

Otherwise, this is useless:

2 Likes