The Issue? You're not scripting in FE.
What do I mean by FE? FE stands for Filtering Enabled, the type of client-server system Roblox has used on all games since 2018. It's a game industry standard, meant to help minimize exploits. Essentially, the system is like this:
Any change on the client stays on the client, it doesn't change on the server.
Any change on the server, though, will make the change on all clients, too. The server cannot touch anything ONLY on the client, however.
As a result, any scripting revolving the client cannot be scripted from a regular script. Assuming this is in ServerScriptService or Workspace (I personally prefer the former), it's not working because you're trying to change the UI on the server. UI is part of the client, so the server doesn't have "access" to it. Therefore, using StarterGui won't do anything on the server. Not to mention that StarterGui wouldn't be how you change the GUI. In order to change UI, you need to use a RemoteEvent. This fires an event down to the client, which can then receive it and change the UI if needed.
This is what'd happen when scripting while respecting FE:
game.local Players = game:GetService("Players")
local P = game.Workspace.Play
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
P.Value = P.Value + 1
end)
Players.PlayerRemoving:Connect(function(player)
print(player.Name .. " left the game!")
P.Value = P.Value - 1
end)
P:GetPropertyChangedSignal("Value"):Connect(function()
if P.Value > 1 then
game.ReplicatedStorage:FireAllClients()
print("Success")
end
end)
You'd need a local script, too now! This is assuming if it's in starter gui:
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
game.Workspace.Beep:Play()
PlayerGui.ScreenGui.TextLabel.Text = "The party is about to start..."
wait(2)
game.Workspace.Beep:Play()
PlayerGui.ScreenGui.TextLabel.Text = "Don't scream too loud, you'll wake him up."
wait(2)
game.Workspace.Beep:Play()
PlayerGui.ScreenGui.TextLabel.Text = "But most importantly, have FUN!"
end)
If you need more reference:
https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
https://developer.roblox.com/en-us/api-reference/property/Workspace/FilteringEnabled
4 comments
How is it running? Is it working but no the way you want it? Or not working at all?
it looks like line 12 he made it >= to 1 player. btw i figured out the number problem for the spectate
You should remove the game.local part in the first line and just do local Players = game:GetService("Players")! I hope this works! PS. In line 12 remove the "=" and just keep the ">"
You're making it too complex..