Gui changing position when im just changing the size?

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:

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)
1 Like

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()

Hope this helped!

1 Like

oh ye damn lol didnt notice that, let mecheck if it works

1 Like
> 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,oreinfo.MaxProgress.AbsoluteSize.Y) 
> 		TS:Create(progress,TweenInfo.new(0.5),{Size = size}):Play()
> 	end
> end)

still not workin (no errors)

1 Like