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

How To Make A Teleporter Gui That Show When A Player Touch A Part?

Asked by 2 years ago

Hi, I have a question, I've made a Teleport Gui for Players on Mermaid High and It's worked in a part that i made on December 2020 but when i change the Gui for another it's doesn't work.

local Part = script.Parent
local Debounce = false

Part.Touched:Connect(function(hit)
    if Debounce == false then
        Debounce = true
        if hit.Parent:FindFirstChild("Humanoid") then
            local plr = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui
            script.ScreenGui:Clone().Parent = plr -- replace "ScreenGui" with the name of your ScreenGui
        end
        wait(1)
        Debounce = false
    end
end)

Also i changed the Name on ScreenGui in the script and stop working

When it's opened: https://gyazo.com/e3da7e8b5c4ed37bc965e4681ecb9548

When it's not opened: https://gyazo.com/49fc25b4c7b71fe68f30143bf85ea0d3

0
Clarify what you're trying to do. Also check in the output for any error messages MarkedTomato 810 — 2y
0
Don't see any reason why this shouldn't be working, maybe make sure of your screengui being visible look at your explorer to make sure it actually doesn't get placed in your playergui DreadfulDeveloper 0 — 2y
0
Ok, Ty Queen1234_XD -26 — 2y
0
The Gui doesn't are in the player gui, What i do? Queen1234_XD -26 — 2y
View all comments (5 more)
0
plr.PlayerGui MarkedTomato 810 — 2y
0
Must be in the Player gui or no? Queen1234_XD -26 — 2y
0
For a GUI to display for a player, it has to be in PlayerGui. If you put your GUI in StarterGui it'll automatically put it in PlayerGui, then you can use the Enabled property on the ScreenGui to enable and disable it. MarkedTomato 810 — 2y
0
Okie. Tysm Queen1234_XD -26 — 2y
0
But the Gui doesn't show when touch a part Queen1234_XD -26 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago

Can anyone can help me?

Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

FIXED CODE

local Part = script.Parent
local Debounce = false

Part.Touched:Connect(function(hit)
    if Debounce == false then
        Debounce = true
        if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
            local PlayerGui = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui
            PlayerGui.ScreenGui.Enabled = true
        end
        game.RunService.Heartbeat:Wait()
        Debounce = false
    end
end)

EXPLANATION

on line 9 make sure to change ScreenGui to the name of yours.

swapped the

wait(1)

with

game.RunService.Heartbeat:Wait()

I think run service might be good in this situation. You should never use wait(n) or wait() because it can be really bad for performance instead wait for events like what I did. There'll always be an event for different situations.

Answer this question