#Problem with script

5 messages · Page 1 of 1 (latest)

vital shell
#

I was writing a script for some stuff and for some reason the debounce works in one of models but not the others

#

here is the script



ClickDetector.MouseClick:Connect(function(player)
    if not debounce then
        
        
    debounce = true
    hitpoints.Value = hitpoints.Value - 1
    local success, newWoodvalue = pcall(function()
        return WoodsDataStore:IncrementAsync(player.UserId, 1)
    end)

    if success then
        print(newWoodvalue)
    end

    if hitpoints.Value <= deathamount then
        
        local success, newWoodsvalue = pcall(function()
            return WoodsDataStore:IncrementAsync(player.UserId, 1)
        end)
        
        if success then
            print(newWoodsvalue)
            wait(0.5)
            Tree:Destroy()
        end
    
        
        
        
        end
        wait(1)
        debounce = false
    end
end)
#

it used to work but then i added this script

local function updateHealth()
    local size = math.clamp(hitpoints.Value / 50, 0, 1)
    local newSize = UDim2.new(size, 0, 1, 0)

    local tweenInfo = TweenInfo.new(
        0.1, 
        Enum.EasingStyle.Linear, 
        Enum.EasingDirection.Out, 
        0, 
        false, 
        0 
    )

    local tween = TweenService:Create(healthBar, tweenInfo, {Size = newSize})
    tween:Play()
end
#

help please

#

Problem with script used to work but now doesnt??