#Why does value not show on text label, and also not print <= 0 then code

6 messages · Page 1 of 1 (latest)

west seal
#

I want the health to display on the text label and the text label to go down but it will not and the <= 0 then does not work./

Here are both scripts

local frame = script.Parent
local measure = frame.Measure
local label = frame.LabelText
local Health = script.Parent.Parent.Parent.Health
local Rock = script.Parent.Parent.Parent.Parent.Rock

if Health.Value <= 0 then
    Rock.Transparency = 0
    Rock.CanCollide = false
    print("health is 0 or under")
end

label.Text =  Health.Value .. "/" .. Health.Value

measure.Size = UDim2.new()

script 2

local Damage = script.Parent.Damage.Value

local Tool = script.Parent

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

local Rock = game.Workspace.Rock
local RockValue = script.Parent.Rock.Value

if RockValue == true then
    mouse.Button1Down:Connect(function()
        local target = mouse.Target
        --print(target)
        if target.Name == "Rock" then
            local distance = (target.Position - player.Character.HumanoidRootPart.Position).Magnitude
            if distance <= 32 then
                Rock.Health.Value -= Damage
                print("Found the target rock within 32")
            else
                print("To far away")
            end
        end
    end)
end
lusty haven
#

u set the health to a variable that never changes so how are you supposed to check the health

#

thats ur mistake

#

use

Health.Changed:Connect(function()
if Health.Value <= 0 then
    Rock.Transparency = 0
    Rock.CanCollide = false
    print("health is 0 or under")
end

label.Text =  Health.Value .. "/" .. Health.Value

measure.Size = UDim2.new()
end)
smoky fox
#

aa i see, ur not sigma enough