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
COMMUNITY QUESTION
Is it possible to detect if a player already has a gui?
1 answer
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Add code
Add the code you used to someone can try to fix it.