I’m fairly new to lua but i’ve been learning for a few months
I tried to make this live system but no matter what i do it doesn’t change the Text labels text?
it works where the server script counts the times you die and each time you die it fires a remote to a local script that changes the gui
--this is the local script
local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local Gui = PlayerGui:WaitForChild('lifeLostGui')
local Frames = Gui.LifeLostFrame.Frame2
local Lives = Frames:WaitForChild('LiveLabel')
local Int = game:WaitForChild('Players').LocalPlayer.Lives.Value
local remote = game.ReplicatedStorage.Liveslost
local guiobject = Lives
remote.OnClientEvent:connect(function ()
Lives.Text = (Int)
end)
-- this is the server script
local Remote = game.ReplicatedStorage.Liveslost
game.Players.PlayerAdded:Connect(function(Player)
local Lives = game.ReplicatedStorage.Lives
Lives.Parent = Player
Player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function()
if Lives.Value > 0 then
Lives.Value -= 1
print(Lives.Value)
Remote:FireClient(Player)
else
print('FullDead')
end
end)
end)
end)
I read it wrong, it is firing when the player has more than 0 lives. It would make more sense to clone lives then put it in the player, that way more people can have lives, not just 1. Also, send the value of the lives through the remote event instead of defining it in the beginning of the script. Then you can change the text to the value sent through the remote event.
If you are changing the value of the TextLabel for the person themself, you don’t need to use server at all.
You can do something simple like
local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local Gui = PlayerGui:WaitForChild('lifeLostGui')
local Frames = Gui.LifeLostFrame.Frame2
local Lives = Frames:WaitForChild('LiveLabel')
local Int = game:WaitForChild('Players').LocalPlayer.Lives.Value
local plr = game.Players.LocalPlayer
LocalPlayer.Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
Lives.Text = "You have ".. tostring(int) .. "health"
end)
local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local Gui = PlayerGui:WaitForChild('lifeLostGui')
local Frames = Gui.LifeLostFrame.Frame2
local Lives = Frames:WaitForChild('LiveLabel')
local LocalPlayer = game:GetService('Players').LocalPlayer
local Int = game.ReplicatedStorage:WaitForChild('Lives')
local Players = game.Players
LocalPlayer.Character.Humanoid.Died:Connect(function()
if Int.Value >0 then
Int.Value -= 1
wait(1)
Lives.Text = (Int.Value)
end
if Int.Value == 0 then
print('FullDead')
end
end)