Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is it not working when I reset and when I am on client?

Asked by 6 years ago

It works once, and when you die, it's working on roblox studio but not in roblox player.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local redzone = hum.MaxHealth/3.8
local greenzone = hum.MaxHealth/1.3

hum.Changed:connect(function()
    if hum.Health <= redzone then
        script.Parent.BackgroundColor3 = Color3.new(255, 0 ,0)
        script.Parent.Parent.Parent.ImageLabel.Visible = true
    end
    if hum.Health > redzone then
        local brickcolor =  BrickColor.new("New Yeller")
        local color = brickcolor.Color
        script.Parent.BackgroundColor3 = color
        script.Parent.Parent.Parent.ImageLabel.Visible = false
    end
    if hum.Health > greenzone then
        local brickcolor =  BrickColor.new("Lime green")
        local color = brickcolor.Color
        script.Parent.BackgroundColor3 = color
    end
    script.Parent.Size = UDim2.new(hum.Health / hum.MaxHealth, 0, 0, 20)
    script.Parent.Parent.TextLabel.Text = math.floor(hum.Health)
end)
0
`hum.HealthChanged` instead of `hum.Changed`? T0XN 276 — 6y
0
Still not working when I reset, btw it's a health gui. Froredion 15 — 6y
0
What isn't "working", exactly? I'd like a bit of clarification. Anything coming up in the output? T0XN 276 — 6y
0
When I reset once, the health gui's changing to 0, but when I reset again, it isn't changing, I think it is because it isn't detecting the character, but when I tried it, it is still the same. Froredion 15 — 6y
0
Where are you putting the script, is it a localscript, is it somewhere in StarterGui, etc. Scarious 243 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Just fixed the script, I only removed the player.Character on the variable "char" to fixed it.

Ad

Answer this question