Basically, I have this script which when the LocalPlayer will hover over a certain object, it will show a BillboardGui, however only to them. I have another brick which will do something else when it has been hovered over.
This is the error:
19:06:31.506 - Players.Player1.PlayerGui.LocalScript:18: attempt to index local 'plr2' (a nil value)
19:06:31.507 - Stack Begin
19:06:31.508 - Script 'Players.Player1.PlayerGui.LocalScript', Line 18
19:06:31.509 - Stack End
And this is the code:
local player = script.Parent.Parent
mouse = game.Players.LocalPlayer:GetMouse()
mouse.Move:connect(function()
if mouse.Target and mouse.Target.Name == "Handle"
then
local plr = mouse.Target.Parent.Parent
print(plr.Name)
mouse.Target.BillboardGui.Enabled = true
script.Value.Value = plr
else
if mouse.Target and mouse.Target.Name == "Part"
then
local plr2 = game.Workspace:FindFirstChild(script.Value.Value)
plr2.ModeratorHat.Handle.BillboardGui.Enabled = false
end
end
end)
It is a localscript so that only the local player can see the BillboardGui. There is also a objectvalue inside the script in order to hold the value of the player who is wearing 'Handle'. I understand that the error is because the script cannot locate where 'plr2' is, however I do not know how to fix it. I want it so that when the player hovers over 'Part', the BillboardGui will disappear (only to them again).
Thanks.

2 comments
Is script.Value an ObjectValue or a StringValue?
ObjectValue