Alright, so I want to figure out how to make a GUI show up for certain players. Here's what I tried. What do I need to do?
Here's my script
game.Players.PlayerAdded:Connect(function(plr) for i, v in pairs(allowed) do if plr.Name == v then game.StarterGui.UTG.Enabled = true end end end)
Also, this is in a script that's in ServerScriptService. (Not localscript.)
To realse this you need three points. SeverScript, ClientScript, RemoteEvent
Put a RemoteEvent on ReplicatedStorage. Your Script ServerScript:
game.Players.PlayerAdded:Connect(function(plr) for i, v in pairs(allowed) do if plr.Name == v then game.ReplicatedStorage.RemoteEvent:FireClient(plr) end end end)
Put a LocalScript ClientScript on StarterGui and write this
local PlayerService = game:GetService('Players') local Player = PlayerService.LocalPlayer local PlayerGui = Player:WaitForChild('PlayerGui') game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function() PlayerGui.UTG.Enabled = true end)
StarterGui is for GUIs that are given to the player instantly. You need to change the PlayerGui of that player.
Here is your script fixed:
game.Players.PlayerAdded:Connect(function(plr) for i, v in pairs(allowed) do if plr.Name == v then plr.PlayerGui.UTG.Enabled = true end end end)