i want to make it so the the function that involves clicking E is only available when the tool is equipped. however idk how to do it can someone help ?
this is what i have
local Plr = game.Players.LocalPlayer
local Char = Plr.Character
local Humanoid = Plr.Character.Humanoid
local Mouse = Plr:GetMouse()
local r = game:GetService("ReplicatedStorage")
local Uis = game:GetService("UserInputService")
local Tool = script.Parent
local CastAnimation = Humanoid.Animator:LoadAnimation(script.Anim)
local AbilityRemote = r.AbRemote.AbilityRemote
local CanUse = false
Tool.Equipped:Connect(function()
CanUse = true
end)
Tool.Unequipped:Connect(function()
CanUse = false
end)
Uis.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
local MousePos = Mouse.Hit.Position
CastAnimation:Play()
AbilityRemote:FireServer("ThrowBall", MousePos)
end
end
end)