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

Why exactly wont mouse.Target work?

So. I am making a cut the wire script with mouse.Target but i cant get it to work why dosent it work? with this script

local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()

function Interact()	
	if Mouse.Target == "Blue" or "Red" or "Yellow" then
		plr.ScreenGui.Frame.Visible = true		
	end
end

2 answers

Mouse.Target is always either a BasePart instance or 'nil' (if the mouse aims at the sky, for example). You're comparing it with a string, so the condition of your 'if' statements always evaluates to false and the block is thus never executed.

A couple questions, first off is this in a local script? If it is, good job, also it's best to use in the StarterPack.

Your issue is that you shouldn't be using your own custom function. Your not even calling it. Do this:

Mouse.Button1Down:connect(function()

-- ALL CODE INSIDE OF INTERACT GOES HERE!

end)

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