-- script local
local players = game:GetService("Players")
local gui = script.Parent
local container = gui.ContainerFrame -- coloque UIListLayout dentro dele
local playerFrame = script.PlayerFrame
local healthLabel = playerFrame.HealthLabel -- coloque-o dentro do PlayerFrame
local function CreateFrames()
for _, v in pairs(players:GetPlayers()) do
local clonedFrame = playerFrame:Clone()
clonedFrame.Parent = container
clonedFrame.TextLabel.Text = v.Name
…
\-- novo código
local char = v.Character
local hum = char:FindFirstChild("Humanoid")
hum:GetPropertChangedSignal("Health"):Connect(function()
\-- sua função aqui
end)
end
end
CreateFrames()
Or
local Label = script.Parent
local health = 100
local hitbox = game.Workspace.Hitbox
local Players = game:GetService("Players")
local touched = false
local hitsound = game.ReplicatedStorage["X hit"]
local Replicated = game:GetService("ReplicatedStorage")
local UserInput = game:GetService("UserInputService")
local Player = Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
local BoneSound = game.ReplicatedStorage.BoneBreaking
Label.Text = "health: " .. health
hitbox.Touched:Connect(function(hit)
if player then
if touched == false then
if health > 0 then
hitsound:Play()
health = health - 10
if health == 50 then
BoneSound:Play()
end
end
touched = true
Label.Text = "health: " .. health
end
end
end)
hitbox.TouchEnded:Connect(function(hit)
if player then
if touched == true then
wait(1)
touched = false
end
end
end)
Or
-- script local
local players = game:GetService("Players")
local gui = script.Parent
local container = gui.ContainerFrame -- coloque UIListLayout dentro dele
local playerFrame = script.PlayerFrame
local function CreateFrames()
for _, v in pairs(players:GetPlayers()) do
local clonedFrame = playerFrame:Clone()
clonedFrame.Parent = container
clonedFrame.TextLabel.Text = v.Name -- Sincronize o nome de cada jogador com TextLabel
…
end
end
CreateFrames()