What I’ve been trying to make is to make a UI visible and kill a player as soon the player reaches 0 or less/negative points in the leaderstats. The purpose is to make the player lose the game when they reach bankruptcy. UI is already in StarterGui and the script is in StarterPlayerScripts. It is also a Local Script. Here’s the script -
local player = game.Players.LocalPlayer
local pointsValue = player:WaitForChild("Balance")
local ui = player.StarterGui.DeathScreen
if pointsValue.Value < 0 then
ui.Enabled = true
local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
else
ui.Enabled = false
end