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

How do I make it so whenever you have a tool equipped, this script disables?

Code: local rp = game:GetService("ReplicatedStorage") local Combat = rp:WaitForChild("Combat")

local UIS = game:GetService("UserInputService") local debounce = false local cds = { 0, 1 } local sequence = "" local curr = 0 local prev = 0

UIS.InputBegan:Connect(function(input,isTyping) if not isTyping then if input.UserInputType == Enum.UserInputType.MouseButton1 then if debounce == false then debounce = true curr = os.clock()

			local PT = curr - prev
			if PT < 1 then 
				sequence = sequence.."L"
				if string.len(sequence) > 4 then 
					sequence = "L"
				end
			else 
				sequence = "L"
			end

			Combat:FireServer(sequence)
		end
	end
end

end)

Combat.OnClientEvent:Connect(function(bool) prev = curr

if bool then 
	wait(cds[2])
	debounce = false 
else 
	debounce = false 
end

end)

1 comment

0

script was posted pretty poorly but first time posting on here, help would be much appreciated.

2 answers

✓ Accepted answer

Use the Equipped and Unequipped function:

--Inside of the Tool
function CoolFunction()
	game.Workspace.LocalScript.Disabled = true --Put wherever the script is inside of here(except for the 'Disabled' and 'True' part)
end

function SadEndingCoolFunction()
	game.Workspace.LocalScript.Disabled = false --Put wherever the script is inside of here(except for the 'Disabled' and 'False part')
end


script.Parent.Equipped:Connect(CoolFunction)
script.Parent.Unequipped:Connect(SadEndingCoolFunction) --When unequipped, it enables again (Remove the function and this line if you don't want it)

Also, the way you do insert the Lua Code is by: Pressing the Lua button, And writing in between the two Lines of


1 comment

0

thank you, it worked!

hey you! have you ever heard of enes? if you are in trouble, better call enes!

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