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

Mouse.Target and Mouse.Target.Parent spamming?

So I am trying to make an efficient script to prevent 'lag', here it is:

local Last = nil

Mouse.Move:connect(function()
	if Mouse.Target ~= Last and Mouse.Target ~= nil then
		Last = Mouse.Target.Parent
		print(Last)
	end
end)

When I change 'Last = Mouse.Target' it doesn't spam the console but when I change it to '..Target.Parent' it spams the console with 'Workspace' not sure why as it is the same as 'Last' so it shouldn't..?

1 comment

0

i dont know what you are using this script for but a debounce will help e.g. stop excessive requests to script

1 answer

Let's run this through for you

  • Last is nil
  • You point at a Part.
  • Part ~= nil, so it sets Last to Part.Parent which happens to be Workspace.
  • You move your mouse a little, still pointing at Part
  • Part ~= nil and Part ~= Workspace, so it sets Last to Part.Parent which happens to be Workspace.

I'm sure by this point you can see the issue. Make sure your conditions match up with your assignments.

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