Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does't the value change?

Asked by 9 years ago
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.

0
Try ((mouse.Target).Parent).Name ? RoyMer 301 — 9y

1 answer

Log in to vote
2
Answered by
Spectrobz 140
9 years ago
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
Ad

Answer this question