so im trying to move my health script from a local script in StarterPlayerScripts, over to a server script in ServerScriptService. because its kinda unsafe for the client to be handling the numbers right? also im gonna do this for my stamina/sprinting script aswell.
HealthManager ServerScript:
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TakeDamage = ReplicatedStorage.TakeDamage
local UpdateHealthUI = ReplicatedStorage.UpdateHealthUI
humanoid.MaxHealth = 200
humanoid.Health = 200
local Health = humanoid.Health
local MaxHealth = humanoid.MaxHealth
RunService.Heartbeat:Connect(function(deltaTime)
Health = humanoid.Health
MaxHealth = humanoid.MaxHealth
UpdateHealthUI:FireClient(player, Health, MaxHealth)
end)
end)
** You are now Level 2! **