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
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.