Hi ive been trying to make a GUI appear at the top of players screens when a player reaches stage 11.
The Gui wont even activate or become visible but when i managed to make that work. It would be permanently stuck on players screens.
while wait(1) do
for i,v in pairs(game.Players:GetChildren()) do
if v.leaderstats.Stage.Value == 11 then
game.StarterGui.Level100.TextLabel.Visible = true
game.StarterGui.Level100.TextLabel.Text = v.Name.." REACHED STAGE 100"
wait()
game.StarterGui.Level100.TextLabel.Visible = false
end
end
end
Heres the code im using if anyone knows how to help! Thankyou!
while wait(1) do
for i,v in pairs(game.Players:GetChildren()) do
if v.leaderstats.Stage.Value == 11 then
game.StarterGui.Level100.TextLabel.Visible = true
game.StarterGui.Level100.TextLabel.Text = v.Name.." REACHED STAGE 100"
wait(1)
game.StarterGui.Level100.TextLabel.Visible = false
end
end
end
When handling player UI, it’s important to do that locally. So:
–In a local script:
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
while wait(1) do
for i,v in pairs(game.Players:GetChildren()) do
if v.leaderstats.Stage.Value == 11 then
playerGui.Level100.TextLabel.Visible = true
playerGui.Level100.TextLabel.Text = v.Name.." REACHED STAGE 100"
wait(1)
playerGui.Level100.TextLabel.Visible = false
end
end
end
Add a LocalScript into StarterPlayerScripts, and paste this inside:
--//Services
local Players = game:GetService("Players")
--//Variables
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local Stage = LocalPlayer:WaitForChild("leaderstats").Stage
--//Functions
local function SetGui()
PlayerGui.Level100.TextLabel.Text = LocalPlayer.Name .." REACHED STAGE 100"
PlayerGui.Level100.TextLabel.Visible = true
task.wait(1)
PlayerGui.Level100.TextLabel.Visible = false
end
Stage.Changed:Connect(function(stageValue)
if stageValue == 11 then
SetGui()
end
end)
if Stage.Value == 11 then
task.spawn(SetGui)
end
--//Services
local Players = game:GetService("Players")
--//Functions
local function DisplayUI(playerName)
for i, player in ipairs(Players:GetPlayers()) do
task.spawn(function()
local PlayerGui = player:WaitForChild("PlayerGui")
PlayerGui.Level100.TextLabel.Text = playerName .." REACHED STAGE 100"
PlayerGui.Level100.TextLabel.Visible = true
task.wait(3)
PlayerGui.Level100.TextLabel.Visible = false
end)
end
end
Players.PlayerAdded:Connect(function(player)
local Stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
Stage.Changed:Connect(function(stageValue)
if stageValue == 11 then
DisplayUI(player.Name)
end
end)
end)