Here is the code I'm dividing the stone's health by its max health to get a scale size for the width of the frame
Here is the code, not sure what's wrong here everything looks okay.
local hitPart = script.Parent
local attack = game:GetService("ReplicatedStorage"):WaitForChild("Attack")
local player = game:GetService("Players").LocalPlayer
local itemHealth = player:WaitForChild("PlayerGui"):WaitForChild("ItemHealth")
local debounce = false
hitPart.Touched:Connect(function(part)
if debounce == false then
debounce = true
if part.Name == "Stone" then
itemHealth.Background.Bar.Size = UDim2.fromScale((part.Health.Value / part.MaxHealth.Value), 0)
print((part.Health.Value / part.MaxHealth.Value))
itemHealth.Background.ProgressText.Text = tostring(part.Health.Value).."/"..tostring(part.MaxHealth.Value)
itemHealth.Background.Title.Text = part.Name
end
player:WaitForChild("AttackTimeout").Value = 10
attack:FireServer(player, part)
wait(.5)
debounce = false
end
end)
