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

Help with making a Gui pop up when a part is touched?

Asked by 7 years ago

I need help making a Gui pop up when a part in workspace is touched. I tried to do it myself but it wasn't working. I restarted the script and I need help with the rest.

local customize = workspace.Custom customize.Touched:connect(function(hit)

end)

0
Thanks for your answers MrMetal13 19 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

Something like this would work:

local customize = workspace.Custom.customize.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if Player then
            Player.PlayerGui.ScreenGui.Enabled = true
        end
    end
end)
Ad
Log in to vote
0
Answered by 7 years ago
part = game.Workspace.partname
gui = script.Gui

part.Touched:connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player.PlayerGui.guinamehere then
gui:Clone().Parent = player.PlayerGui
end
end)

This piece of code should work.

Change the variable part to the parts location that you want to activate the touched function.

Change the variable gui to the gui's location

Change guinamehere to the name of the GUI

If you'd like the part to remove the gui if its already open we can do this by adding something simple:

part = game.Workspace.partname
gui = script.Gui

part.Touched:connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player.PlayerGui.guinamehere then
gui:Clone().Parent = player.PlayerGui
elseif player.PlayerGui.guinamehere then
player.PlayerGui.guinamehere:Destroy()
end
end)

If this doesn't work please let me know any error(s) outputted and I'll help you fix it.

Answer this question