so im creating a mining script for my game, but im having issues with the mining progress bar. it is escaping when im trying to change its size.
heres a gif:
and here is the script i am using:
local remote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("MPAdddOrIncrease")
local plr = game.Players.LocalPlayer
local TS = game:GetService("TweenService")
remote.OnClientEvent:Connect(function(pickaxepower,oremaxhealth)
local oreinfo = plr.PlayerGui.OreMiningProgress.Main
if oreinfo:FindFirstChild("Progress") == nil then
local progress = oreinfo.MaxProgress:Clone()
progress.Name = "Progress"
progress.Parent = oreinfo
local size = UDim2.new(0,oreinfo.MaxProgress.AbsoluteSize.X/oremaxhealth * pickaxepower,0,oreinfo.MaxProgress.AbsoluteSize.Y)
progress.Size = UDim2.new(0,0,0,oreinfo.MaxProgress.AbsoluteSize.Y)
progress.BackgroundColor3 = Color3.fromRGB(215, 0, 0)
TS:Create(progress,TweenInfo.new(0.5),{Size = size}):Play()
else
local progress = oreinfo.Progress
local size = UDim2.new(0,progress.AbsoluteSize.X+oreinfo.MaxProgress.AbsoluteSize.X/oremaxhealth * pickaxepower,0,0)
TS:Create(progress,TweenInfo.new(0.5),{Size = size}):Play()
end
end)
It’s not changing the position, what it’s changing is the Y Size. As seen here in part of your code: progress.Size = UDim2.new(0,0,0,oreinfo.MaxProgress.AbsoluteSize.Y)
Then you go on to tween it but with the Y size as zero: local size = UDim2.new(0,progress.AbsoluteSize.X+oreinfo.MaxProgress.AbsoluteSize.X/oremaxhealth * pickaxepower,0,0)
So to fix this you would do: local size = UDim2.new(0,progress.AbsoluteSize.X+oreinfo.MaxProgress.AbsoluteSize.X/oremaxhealth * pickaxepower,0,oreinfo.MaxProgress.AbsoluteSize.Y) TS:Create(progress,TweenInfo.new(0.5),{Size = size}):Play()