Tunnells
(PlaySage)
February 9, 2021, 5:25pm
#1
Hi im trying to Enable/Disable/Edit A Gui from the ServerScript for All Players to see i tried this but it doesnt work local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(Player)
if Player.Parent:FindFirstChild("Humanoid") then
local PlayerService = game:GetService("Players")
local Player = PlayerService:GetPlayerFromCharacter(Player.Parent) -- GetPlayerFromCharacter
Player.PlayerGui.UI.Enabled = false
end
end)
2 Likes
Kaid3n22
(Kaiden)
February 9, 2021, 5:27pm
#2
just Player.PlayerGui
nothing to do with the if statement is needed. Like this:
local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(Player)
Player.PlayerGui.UI.Enabled = false
end)
The PlayerAdded function checks if someone joins the game. It already leads to the player in the Players Category. No need to try finding the player.
1 Like
lluckvy
(aaron)
February 9, 2021, 5:27pm
#3
Humanoid isn’t a child of player, and this line in general is unnecessary. You don’t need to check if the player will have a Humanoid
You can try instead
Player:WaitForChild('PlayerGui').UI.Enabled = false
You have 2 player variables. You only need 1
local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(Player)
Player:WaitForChild('PlayerGui').UI.Enabled = false
end)
1 Like
Tunnells
(PlaySage)
February 9, 2021, 5:34pm
#4
17:33:48.195 UI is not a valid member of PlayerGui “Players.Tunnells.PlayerGui” - S doesnt work
1 Like
lluckvy
(aaron)
February 9, 2021, 5:37pm
#6
What’s the name of your UI? You have to replace it with its correct name of course
1 Like
Tunnells
(PlaySage)
February 9, 2021, 5:38pm
#7
The name is UI im not sure why its not working
1 Like
Tunnells
(PlaySage)
February 9, 2021, 5:39pm
#8
TEST.rbxl (23.5 KB) This is what i did
1 Like
lluckvy
(aaron)
February 9, 2021, 5:40pm
#9
Can you show us your explorer of StarterGui or PlayerGui? Not sure what’s going on there
1 Like
dollychun
(dollychun)
February 9, 2021, 5:42pm
#12
Try
Player:WaitForChild('PlayerGui'):WaitForChild('UI').Enabled = false
script accessing ui before it loads
1 Like
lluckvy
(aaron)
February 9, 2021, 5:43pm
#13
Try this instead. I don’t know if the server recognizes there’s a GUI there
local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(Player)
Player:WaitForChild('PlayerGui'):WaitForChild('UI').Enabled = false
end)
what @dollychun said lol
9 Likes
Tunnells
(PlaySage)
February 9, 2021, 5:44pm
#14
Thank you it works but can i like edit the script while
like
change the text and stuff
1 Like
2112Jay
(2112Jay)
March 25, 2022, 7:42pm
#15
Using what has been posted … to do that, just replace this line …
Player:WaitForChild(‘PlayerGui’):WaitForChild(‘UI’).Enabled = false
With this …
local ui = Player:WaitForChild(‘PlayerGui’).UI
ui.ScreenGui.Frame.TextLabel.Text = “Whatever you want to say”
ui.Enabled = true
3 Likes