So I tried to make a tool that when you hold it you can use these abilities that are linked to keys. I can do the keybind part but how do I make it so that it only works whilst the tool is being held. If anyone needs it, my code I currently have is below:
local equipped = false local tool = script.Parent
local re = game.ReplicatedStorage.EarthMagic:WaitForChild("EarthWallRE")
local mouse = game.Players.LocalPlayer:GetMouse()
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(inp, processed) tool.Equipped:Connect(function() if equipped == true and inp.KeyCode == Enum.KeyCode.R then
re:FireServer(mouse.Hit)
end
end)
end)
uis.InputBegan:Connect(function(inp, processed) tool.Unequipped:Connect(function() if equipped == false and inp.KeyCode == Enum.KeyCode.R then
end
end)
end)
I also might need to mention I am not used to coding in this language.
