So, I am modifying an open-source combat module (Advanced Melee System) to fit the purposes for my game. in it, the ranged script for the bows fires a projectile based on where you point your mouse. however, i need to implement something like Mouse.TargetFilter = game.workspace.whatever
so that the Mouse hit position completely ignores certain objects. I have no real idea how this can be accomplished because I am unfamiliar with roblox-ts in its entirety.
Here’s the code below:
-- Compiled with roblox-ts v1.2.7
local TS = require(game:GetService("ReplicatedStorage"):WaitForChild("AMS-rbxts_include"):WaitForChild("RuntimeLib"))
local Roact = TS.import(script, TS.getModule(script, "@rbxts", "roact").src)
local _services = TS.import(script, TS.getModule(script, "@rbxts", "services"))
local UserInputService = _services.UserInputService
local RunService = _services.RunService
local Janitor = TS.import(script, TS.getModule(script, "@rbxts", "janitor").src).Janitor
local MousePos
do
MousePos = Roact.Component:extend("MousePos")
function MousePos:init(props)
self.janitor = Janitor.new()
self:updatePosition()
end
function MousePos:updatePosition()
if not UserInputService.MouseEnabled then
self:setState({
position = UDim2.fromScale(0.5, 0.5),
})
else
local Pos = UserInputService:GetMouseLocation()
self:setState({
position = UDim2.fromOffset(Pos.X, Pos.Y),
})
end
end
function MousePos:didMount()
self.janitor:Add(RunService.Heartbeat:Connect(function()
return self:updatePosition()
end))
end
function MousePos:willUnmount()
self.janitor:Cleanup()
end
end
return {
MousePos = MousePos,
}
Any help would be appreciated. Thanks! If you think I should be looking in a different area or this is not the proper code to handle something like this, let me know and I can provide at least one other alternative place I know of, but I believe this is the correct script.