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

How do I get this script to clone a GUI and put it in the PlayerGUI?

Asked by 8 years ago

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.

0
It's PlayerGui not PlayerGUI. Lua is case sensitive. M39a9am3R 3210 — 8y

1 answer

Log in to vote
0
Answered by
rexbit 707 Moderation Voter
8 years ago

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

Ad

Answer this question