Hello fellow developers! I am currently creating an input detection system (mainly for m1 combat) and I need to be able to detect when the mouse hovers over any gui, roblox UI included, so i can stop the “hold” event. Here is my code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InputR = ReplicatedStorage.Remotes.Input
local player = game.Players.LocalPlayer
local InputService = game:GetService("UserInputService")
local camera = game.Workspace.CurrentCamera
local CAS = game:GetService("ContextActionService")
local inputs = {
[Enum.UserInputType.MouseButton1] = {
["SkillName"] = "M1";
}
}
local function sendtoServer(key,...)
local args = {key, ...}
InputR:FireServer(
args
)
end
local hold = nil
for i,v in inputs do
CAS:BindAction(v.SkillName,function(_,inputObj,_)
if inputObj == Enum.UserInputState.Begin then
if i == Enum.UserInputType.MouseButton1 then
hold = game["Run Service"].RenderStepped:Connect(function()
sendtoServer(v, {
"test"
})
end)
end
elseif inputObj == Enum.UserInputState.End then
if i == Enum.UserInputType.MouseButton1 then
if hold then
hold:Disconnect()
hold = nil
end
end
end
return Enum.ContextActionResult.Pass
end, false, i)
end
If anyone needs further explanation on what I am requiring, just let me know.