Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would make a Script run if a Tool is Equipped or not?

Hey there,

I've got this script that runs no matter if the Tool is Equipped or not so i would need it to only run if a the Tool is equipped if not it would do nothing.

Script:

local input = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local Swing = rs:WaitForChild("Swing")
local hurt = script.Parent.Hurt.Value
local wep = script.Parent
local cooldown = .5
local db = false

	input.InputBegan:Connect(function(input,isTyping)
	if isTyping then
		return
		elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
		if db == false then
		db = true
		print("Clicked")
		Swing:FireServer(cooldown)
		wait(cooldown)
		db = false
		end
	end
end)

Swing.OnClientEvent:Connect(function()
	wait(cooldown)
	db = false
end)

Thanks,

1 comment

0

Got it, Check below is anyone else is interested!

1 answer

	wep.Equipped:Connect(function(mouse)
	equip = true print("Equipped")
	wep.Unequipped:Connect(function(mouse)
	equip = false print("Unequipped")
	end)

This discussion is preserved as it was. New answers, comments, and votes are closed.