So Im trying to make a script which detects if a mouse button is being held if it is then it’ll print(“Not Held”) If it is then it’ll print(“Held”) I’m aware there are tutorials about this but im not sure how I can implement my code into them. In the explorer I have a remote event and a cooldown script which doesn’t matter that much. This is the local script
function onButton1Down(mouse)
if script.Parent.Cooldown.Value == 0 then
script.Parent.RemoteEvent:FireServer()
script.Parent.Cooldown.Value = 7
else
return
end
end
function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onSelected)
It fires the remote event after a given time and then the script detects it and executes this code:
local UserInputService = game:GetService("UserInputService")
local Tool = script.Parent.Parent
local play = Tool.Parent.Parent
local char = play.Character
local hum = char.Humanoid
local root = char.HumanoidRootPart
script.Parent.Parent.RemoteEvent.OnServerEvent:Connect(function(player)
local function discharged()
print("Held")
end
local function charged()
print("NotHeld")
end
end)
I don’t know where and how to add something which detects when the mouse button is held. My aim is for it to fire the function charged when its held and if its not it fires discharged.