Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Mouse ignore models help?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.