0

# How to get only one player in a GUI and not all?

So I'm having a problem where I want ONLY the person who touched a pad to see a GUI, the problem is that I think the i,v in pairs is taking all players, even despite me using the PlayerGui. How can I get around this? LocalScript:

local debounce = false
local function popup()
if not debounce then
debounce = true
game.Workspace.BackroomsSound:Stop()
for i,v in pairs (game.Players:GetPlayers()) do
local Frame = v.PlayerGui.LevelChanges.PipeDreams
local Text = Frame.text
Frame.Visible = true
wait(5)
while true do
script.Parent.BackgroundTransparency = script.Parent.BackgroundTransparency + 0.05
wait(0.05)
if  script.Parent.BackgroundTransparency >= 1 then
break
end
end
script.Parent.text.TextTransparency = 1
game.Workspace.BackroomsSound:Play()
wait(1)
debounce = false
end
end
end



0

You can check if the player touching the pad is LocalPlayer (keep in mind that LocalPlayer only exists in local scripts, so don’t attempt this on server scripts).

You should also replace the loop with TweenService, as it is smoother and does not create unnecessary burdens.

Lastly, try not using wait(), but if you must, use task.wait(), it is an “improved” version of wait().

So something like this:

local Players = game:GetService('Players')
local TweenService = game:GetService('TweenService')

local debounce = false
local localPlayer = game.Players.LocalPlayer

if localPlayer.Name == hit.Parent.Name and not debounce then
debounce = true

local Frame = localPlayer.PlayerGui.LevelChanges.PipeDreams
workspace.BackroomsSound:Stop()
Frame.Visible = true