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

How do you make a GUI pop up on someones when they touch a part?

Asked by 10 years ago

I'm not very good at scripting, and I don't know much about it, and I don't know how to make a GUI. When I did this, I really took things I know and things I thought were going to work and made this:

function onTouch if 
    game.Players onTouch
    function Display game.Workspace.ScreenGui
end

I don't know if this script would display a ScreenGui when I touched the part. (This script is in the part I'm trying to use).

3 answers

Log in to vote
0
Answered by 10 years ago

This script uses the Touchedevent. Then used the GetPlayerFromCharacter method to make sure that it is a player. Then I make sure the player does not have the gui already using FindFirstChild. Then clone it into their PlayerGuiusing the Clonemethod.

Just add the path the the gui.

local Gui = Game:GerService("ServerStorage").???

script.Parent.Touched:connect(function(Part)
local Player = Game.Players:GetPlayerFromCharacter(Part.Parent)
    if Player and not Player.PlayerGui:FindFirstChild(Gui.Name) then
        Gui:Clone().Parent = Player.PlayerGui
    end
end)
Ad
Log in to vote
0
Answered by
Nickoakz 231 Moderation Voter
10 years ago
function onTouch if 
    game.Players onTouch
    function Display game.Workspace.ScreenGui
end

I think you just made this up...

script.Parent.Touched:connect(function(p)
    if p~=nil and game:getService("Players"):getPlayerFromCharacter(p.Parent) then
        local me=game:getService("Players"):getPlayerFromCharacter(p.Parent)
        if me.PlayerGui:findFirstChild("Message")==nil then
            local msg=Instance.new("Message",me.PlayerGui)
            msg.Text="Text here"
            game:getService("Debris"):AddItem(msg,5)
        end
    end
end)

This will give the player a simple message in the center of their screen for 5 seconds.

Log in to vote
0
Answered by
Cizox 80
10 years ago
debounce = false
script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not debounce then
debounce = true
local gui = Instance.new('ScreenGui')
gui.Parent = player.PlayerGui
local frame = Instance.new('Frame')
frame.Parent = gui
frame.Size = UDim2.new(0, 50, 0, 50)
debounce = false
end
end)

You can edit the GUI properties from there. Use this as a reference for the Frame properties:

http://wiki.roblox.com/index.php/RBX.lua.Frame_(Object)

Answer this question