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

How do I make a screenGui pop up on click?

Asked by 9 years ago

I know it has something to do with cloning to to the StarterGui, but I don't know how. Any help would be appreciated. Here is the start of the script.

function show()

    end 

script.Parent.ClickDetector.MouseClick:connect(show)

3 answers

Log in to vote
0
Answered by 9 years ago
function show()
plr:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
end

script.Parent.ClickDetector.MouseClick:connect(function(plr)
show()
end)
Ad
Log in to vote
0
Answered by 9 years ago

You where correct with the function, So to continue on that we need to clone the gui into the players Playergui

function FindClosestPlayer()
dist = 20
pl = ""
    for i,v in pairs(game.Players:GetPlayers()) do
        if v.Character ~= nil then
            if (v.Character.Torso.Position - script.Parent.Position).magnitude < dist then
                dist = (v.Character.Torso.Position - script.Parent.Position).magnitude
                pl = v.Name
            end
        end
    end
    if pl ~= "" then
        return pl
    end
end

function onClicked()
    for i,v in pairs(script:GetChildren()) do
        if v:IsA("ScreenGui") then
            cl = v:clone()
            pl = FindClosestPlayer()
            if game.Players:FindFirstChild(pl) ~= nil then
                if game.Players:FindFirstChild(pl).PlayerGui:FindFirstChild(v.Name) == nil then
                    cl.Parent = game.Players:FindFirstChild(pl).PlayerGui
                    game.Players:FindFirstChild(pl).Character.Humanoid.WalkSpeed = 0
                end
            end
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Gui must be in the script, and script in the part.

Hope this helps

0
error: Script:3 attempt to index global 'hit' (a nil value) Here is what my script looks like function show() guin = control --Gui name if game.Players:findFirstChild(hit.Parent.Name) ~= nil then player = game.Players[hit.Parent.Name] if player.PlayerGui:findFirstChild(guin) == nil then gui = script.Control:clone() gui.Parent = player.PlayerGui My_Comment 95 — 9y
0
Ok, i fixed it, its a bit longer but, its more effective then my original code ghosteffectz 115 — 9y
0
I do like that the character is stuck into position when clicked, but i need it to let them move when the Gui is out of their playerGui. My_Comment 95 — 9y
0
And, maybe i can also put a walkspeed=16 script inside my close script. the close script is 3 Parents away from the ScreenGui, if that helps you. My_Comment 95 — 9y
0
Hello?? My_Comment 95 — 9y
Log in to vote
0
Answered by 9 years ago

Just do this:

function Clicked() game.StarterGui.ScreenGui.Frame.Visible = true end script.Parent.MouseButton1Down:connect(Clicked)

-- This is just a basic way of trying to make a Gui show up. If you want to get advanced you would use a loop.

Answer this question