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

How to chech with mouse.hit if the player clicks on a part SIMPLE??

i have a simple problem i have a local script and when the player clicks this code runs but this doesn't work thank you

if mouse.Hit==game.Workspace.twofive.CFrame then
		print("hiiiiiiiiiiiiiiiiiit")

end

1 answer

✓ Accepted answer

mouse.Hit is a CFrame. CFrames have to be precise to be compared equal to each other. The part itself will have the cframe at the center of its volume. The mouse.Hit will have the cframe at the edge of the part where the part interrupted the ray.

To fix this problem, instead do:

if mouse.Target == workspace.twofive then
	print("Hit")
end

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