Basically what I mean is I need a script to identify a player’s username then print that into a GUI. For example, if the player’s name is ‘the_yesO12’ then it would print that player’s username in the GUI and only pop of for that player and if there is other players in the server they would not see it. But when they do, their username is in the GUI.
I am going to need you to elaborate on what you want to do. Do you want it to detect when a player joins and update a GUI? Are you making a custom OverheadUI?
So I am making GUI appear for a single player after they touch a specific part. But it won’t choose a random player in the server it will choose the player who is currently seeing the GUI.
If I am correct, you’re using the :Touched()
event.
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then -- this makes sure that what is hit is actually a player and not just a random part otherwise whatever you put in your code will error
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
local UI = script.Parent.UI -- insert your location here
local NewUI = UI:Clone()
NewUI.Parent = player.PlayerGui
end
end)
Yes I am, but I have already figured out how to make the GUI pop up, just not how to get the name to appear.
That’s a lot of GUI’s are you sure you need 593485747
From what I could understand from the other posts, you want a random player to be able to see the Gui when someone touches a part?
local Debounce = false
local Part = script.Parent
Part.Touched:Connect(function(Hit)
if not Debounce then
Debounce = true
local Players = game.Players:GetPlayers()
local RandomPlayer = Players[math.random(1, #Players)]
print(RandomPlayer)
if RandomPlayer then
local Gui = game.ReplicatedStorage.Gui:Clone()
Gui.Parent = RandomPlayer.PlayerGui
end
wait(5)
Debounce = false
end
end)
No, a specific player. the player who had touched the part which makes the GUI pop up.
What do you mean ‘that’s a lot of UIs’, it’s just 2 variables? Also, I would rather have more lines than keep have my lines long (just personal preference).
The name would just be local PlayerName = player.Name
.
There’s no cooldown when touching the part, which would result in the Event firing numerous times & resulting in multiple clones of the UI
(Anyways)
Just do this then
local Debounce = false
local Part = script.Parent
Part.Touched:Connect(function(Hit)
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if not Debounce and Player then
Debounce = true
print(Player)
local Gui = game.ReplicatedStorage.Gui:Clone()
Gui.Parent = Player.PlayerGui
wait(5)
Debounce = false
end
end)
I’m trying to help him not give him the whole solution — people don’t learn like that. Also, the above is kind of eh, if I was making a debounce I wouldn’t do it like that, I would try to see if there was already a UI. if not player.PlayerGui:FindFirstChild("UIName") then