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

Why does't the value change?

local mouse = game.Players.LocalPlayer:GetMouse()
local p = workspace.part
local plr = "Head"

while true do
	wait()
	if mouse.Target == nil or mouse.Target == p  then
		script.Parent.Value = ""
	elseif mouse.Target == plr then
		script.Parent.Value = plr.Parent.Name
	else
		script.Parent.Value = mouse.Target.Name
	end
end

Everything works except elseif mouse.Target == plr then script.Parent.Value = plr.Parent.Name

Whenever I mouse over a head the value is 'Head' and not 'Player1' (the head belongs to 'Player1')

No errors either.

1 comment

0

Try ((mouse.Target).Parent).Name ?

1 answer

✓ Accepted answer
elseif mouse.Target == plr then

You are trying to compare a string value plr ( ="Head") to an actual object. Try with this:

elseif mouse.Target.Name == plr then
	script.Parent.Value = mouse.Target.Parent.Name

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