Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

mouse.TargetFilter adds and removes filtered part alternately?

Asked by 4 years ago

localscript:

local tool = script.Parent.Parent
local isenabled = false
local plr = game.Players.LocalPlayer
local char = plr.Character
local debounce = false
tool.Activated:Connect(function()
    isenabled = true


    while true do
        wait()
        if isenabled == true and not debounce then
            debounce = true
            local mouse = plr:GetMouse()
            local mousepos = mouse.Hit
            local mousetarget = mouse.Target
            mouse.TargetFilter = mousetarget
            print(mouse.TargetFilter)

            script.Parent.SendMouse:FireServer(mousepos,mousetarget)
            wait(0.5)
            debounce = false
        end
    end

end)



tool.Deactivated:Connect(function()
    isenabled = false
end)

regularscript:

script.Parent.SendMouse.OnServerEvent:Connect(function(plr,mousepos,mousetarget)



    local copy = game.ServerStorage.Projectiles.MelterShot:Clone()
    copy.Parent = game.Workspace
    copy:SetPrimaryPartCFrame(CFrame.new(script.Parent.Parent.FirePoint.Position,mousepos.Position))
copy.CoreFolder.Go.Disabled = false
copy.CoreFolder.TeamID.Value = script.Parent.Parent.Parent.InfoFolder.TeamID.Value
end)

these scripts fire projectiles in the direction of the mouse. when the first shot is fired, the targetfiltered part is not ignored, but when the second shot is fired the part IS ignored, it alternates ignoring and not ignoring, why is it doing this and what can I do to have it always ignore?

Answer this question