This question exists solely in my lack of lua knowledge eue.
I'm trying to make a shopkeeper and when you walk near the NPC, it displays a GUI on your screen, simple enough.
function Enter() script.NPCDialauge:Clone().Parent = v.Players.PlayerGUI script.NPCDialauge:TweenPosition(UDim2.new(0, 500,0, 250), "In", "Sine", 2, true) end while true do for i, v in pairs (game.Players:GetChildren()) do if (v.Character.Torso.Position - script.Parent.Position).magnitude <= 10 then Enter() end end wait() end
How do I get this to clone the GUI and put it in the character who nears the NPC? You can see the obvious error DX I just don't know how to fix it.
v
on line 02 is undefined, to fix, place a Parameter
in Enter
function.
function Enter(v) script.NPCDialauge:Clone().Parent = v.PlayerGui script.NPCDialauge:TweenPosition(UDim2.new(0, 500,0, 250), "In", "Sine", 2, true) end while true do for i, v in pairs (game.Players:GetChildren()) do if (v.Character.Torso.Position - script.Parent.Position).magnitude <= 10 then Enter(v) end end wait() end