Hi, I am trying to create a health system that is similar to Super Mario Galaxy and the like.
-
What do you want to achieve? A working health system
-
What is the issue? It doesn’t work
-
What solutions have you tried so far? Tried putting the script into the HUD Element, Workspace part, and the ServerScriptService. IT STILL DOESNT WORK AAAAAAAAAAAAA
Sorry if my code looks this bad. It’s an amalgamation of many other codes.
local Health = {}
local Player = game.Players.LocalPlayer
local hurt = workspace.damageBrick.Part
local Cooldown = false
local WaitTime = 2
local HUD = Player:FindFirstChild('HUD')
local Life1 = HUD.ImageLabel.Life1
local Life2 = HUD.ImageLabel.Life2
local Life3 = HUD.ImageLabel.Life3
local Life0 = HUD.ImageLabel.Life0
game.Players.PlayerAdded:Connect(function(Player)
Health[Player.Name] = {Health = 3}
end)
hurt.Touched:Connect(function(Hit)
if Cooldown == false then
Cooldown = true
local CheckHumanoid = Hit.Parent:FindFirstChild("Humanoid")
if CheckHumanoid then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
Health[Player.Name].Health = Health[Player.Name].Health -1
if Health[Player.Name].Health == 2 then
HUD.FireClient(Player)
Life3.Visible = false
Life2.Visible = true
Life2.Position = UDim2.new(0, 0, 0, math.sin(tick() * 10) * 2)
HUD.FireClient(Player)
end
if Health[Player.Name].Health == 1 then
HUD.FireClient(Player)
Life2.Visible = false
Life1.Visible = true
Life1.Position = UDim2.new(0, 0, 0, math.sin(tick() * 10) * 2)
HUD.FireClient(Player)
end
end
wait(WaitTime)
Cooldown = false
end
end)
This code is in ServerScriptService.
Might I have any insight to what am I doing wrong?
(now that i think about it, its all wrong)
p.s. pls send help this is the only roadblock i encountered