Hello, I want to make a script that the GUI will only show to me. but I don’t know how to script that.
I would like to know how I can make this script. Thank you!
Put a Localscript inside the GUI that checks the player’s name or the userid.
heres a quick idea: If Player.Name ~= “Ojnim0702” then Gui:Destroy() end
You could do something similar to
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
if (player.UserId) == yourid then
yourgui.Visible = true
end
end)
Make sure to do this in a LocalScript.
A better practice is to use UserId, since the name can change, but the UserId cannot.
There’s really no need to have to put it in everyone’s StarterGui and then destroy it for people who aren’t you. A simple way would be to put it in ServerStorage and have a script listen for when players join and just clone it to who needs to have itonly
Since I’m assuming the place belongs to you, all you need to do is just use the CreatorId propert of the game to get the UserId
Example, Script in ServerScriptService
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ownerGui = --Location of your Gui in ServerStorage
Players.PlayerAdded:Connect(function(player)
if player.UserId == game.CreatorId then
ownerGui:Clone().Parent = player:WaitForChild("PlayerGui")
end
end)
Is there also a way to use tools but the backpack ui isn’t there? Like you can’t visibly see the backpack ui but its there
Localscript
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
-- Simple: Place in ServerScriptStorage
local GUIRef
game.Players.PlayerAdded:Connect(function(player)
if player.UserId == x then
local newGui = GuiRef:Clone()
newGui.Parent = player.PlayerGui
end
end)
Simple as that really.
If I do that and I do :ball It won’t give me anything
Okay I accidentall replied to the wrong person, just parent it to the Player’s character, sorry scripting1st
Hi, I have few questions,
- Do I have to change the ownerGui to the name of my Gui?
- Do I have to change game.CreatorId to game.“my profile Id”?
- You said to put the Gui into the ServerStorage, but do I need to duplicate it and put one in StarterGui too? (instead of only putting the Gui into ServerStorage).
Thank you!
In the ownerGui variable, include the location of the gui in ServerStorage, so if the name of the gui is Bob, just do local ownerGui = ServerStorage.Bob
If you are not the owner of the game then yes, if you are, then you can keep it like that
No, because then it’s not needed to do it like this. It’s better to do it like this anyways since you want it so only specific people can use the gui. ALl you really need is the ScreenGui in ServerStorage
Ok, Thank you! I will test the script now.