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)
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)
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)
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thanks for your answers