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

Mouse ignore models help?

Asked by
tomekcz 174
5 years ago
Edited 5 years ago
local mouse = game.Players.LocalPlayer:GetMouse()
local Target = mouse.Target
local TargetParent = mouse.Target.Parent
local Hit = mouse.Hit
local Delay = false




mouse.KeyDown:Connect(function(key)
    if key == "f" then
        print(key)
        if  Delay  == false then
        print("delay")
            Delay = true
            print(TargetParent)
            print(Target)
            local Humanoid = TargetParent:FindFirstChild("Humanoid")
            print(Humanoid)
            if Humanoid then
                print((Hit - Target.Position).Magnitude)
                if (Hit - Target.Position).Magnitude < 10 then
                    print("Hit")
                end
            end
            wait(1)
            Delay = false
        end
    end
end)

when i aim mouse into dummy it shows other thing

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

you should update the Current Mouse Target and Hit, like this:

mouse.KeyDown:Connect(function(key)
    if key == "f" then
        Target = mouse.Target
    TargetParent = mouse.Target.Parent
    Hit = mouse.Hit
    --(the rest of the script goes here)
    end
end)

Also mouse.KeyDown is Deprecated so you should use UserInputService

Ad

Answer this question