So here I have a script that looks at the current health of the wall and the maximum and looking at it adjusts the health bar, but for some reason instead of was like this (this is just an example of what I want to achieve if for example the wall was half of the maximum health):
no it did not help, well as you asked a full script:(but only the part that relates to the wall)
local player = game:GetService("Players").LocalPlayer
local tween = game:GetService("TweenService")
local debounce1 = true
local debounce2 = true
local function dynamiteTouched()
if script.Parent:WaitForChild("DynamiteValue").Value ~= nil then
script.Parent:WaitForChild("DynamiteValue").Value.Touched:Connect(function(hit)
if hit.Name == "Sand_1" and debounce2 == true then
debounce2 = false
hit:FindFirstChild("Current").Value -= player.leaderstats.Damage.Value
hit:FindFirstChild("SurfaceGui").HpCount.Text = hit:FindFirstChild("Current").Value.. " / ".. hit:FindFirstChild("Max").Value
local surfaceGui = hit:FindFirstChild("SurfaceGui")
local greenGround = hit:FindFirstChild("SurfaceGui"):FindFirstChild("BackGround").GreenGround
greenGround:TweenSize(UDim2.new(0, 0, hit:FindFirstChild("Current").Value / hit:FindFirstChild("Max").Value, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5)
if hit:FindFirstChild("Current").Value <= 0 then
wait(0.1)
hit.Parent = game:GetService("ReplicatedStorage").RPWalls
local vfx = workspace.Smoke_1:Clone()
vfx.Parent = workspace.vfx
vfx.Position = hit.Position
vfx.Anchored = true
vfx.ParticleEmitter:Emit()
wait(0.4)
vfx:Destroy()
end
wait(1)
debounce2 = true
end
end)
end
end
script.Parent:WaitForChild("DynamiteValue"):GetPropertyChangedSignal("Value"):Connect(dynamiteTouched)
Looking at the provided script, it seems like the issue lies in the line where you are using greenGround:TweenSize(). The code snippet you shared is attempting to adjust the size of greenGround based on the current and maximum values of the wallβs health.
To fix the issue, you need to update the greenGround:TweenSize() function to use the correct parameters. Hereβs the corrected line of code:
In this corrected version, we maintain the original width of greenGround by using greenGround.Size.X.Offset as the width component in the UDim2 size. This ensures that the width remains the same while only adjusting the height based on the health values.