Still have questions? Join our Discord server and get real time help.
0

# Is it possible to detect if a player already has a gui?

So basically I made a part that on touched gives you a gui, but if you keep touching it you keep getting the gui. Is it possible to make it so it detects if you already have the gui. As from what I have seen the server even with knowing who the player is cannot see what gui they have

0
Add code DinozCreates 746 — 2mo
0
Add the code you used to someone can try to fix it. Crojix 6 — 2mo

0

You can add some lines of code that verifies so that if the player already has the GUI the function won't fire

local players = game:GetService("Players")
local part = script.Parent
local GUI = part:WaitForChild("YourGUI") --//Pretend the GUI is located there

local function onTouched(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")

if humanoid then --//Checks if it has a humanoid
local playerName = hit.Parent.Name
local sPlayer = players:WaitForChild(playerName)
local playerGui = sPlayer:WaitForChild("PlayerGui")

if playerGui:FindFirstChild("YourGUI") then return end --//Checks if the GUI is already at the player's screen, if true then return end

local newGUI = GUI:Clone()
newGUI.Parent = playerGui --//Clones the GUI to the player's screen
end
end

part.Touched:Connect(onTouched)


This is the first solution that came into my head, warn me if any error pops up