Gui tween always goes to top left corner

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i want to tween a gui to move up and down when the player walks
  2. What is the issue? Include screenshots / videos if possible!
    the gui always goes to the top left corner no matter what positition i tween it to
  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    i have tried changing the anchor point

local player = game.Players.LocalPlayer 
local parent = script.Parent 
local tweenservice = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,true)
local runservice = game:GetService("RunService")
local humanoid = player.Character:FindFirstChild("Humanoid")
local isplaying = false

local function move()
	local position1 = UDim2.new({0.5, 0},{0.75, 0})
	local tween = tweenservice:Create(parent,tweeninfo,{Position = UDim2.new(position1)})
	tween:Play()
end

local function walking()
	if humanoid then
		if humanoid.MoveDirection.Magnitude > 0 then
			if isplaying == false then
			isplaying = true
			move()
			task.wait(2)
			isplaying = false
			end
			return 
		end		
	end	
end

runservice.RenderStepped:Connect(walking)

You tried creating a UDim2 from a UDim2.

Try replacing the tween dictionary with just

{Position = position1}

i did that but it still goes to the corner

You may also need to remove the { and } from the defining of the UDim2. Not 100% sure on this one, but worth a try

thank you so much it worked, but why did the curly brackets make it do that? i dont understand

I guess UDim2 didn’t actually accept the brackets as a valid input (even though they get displayed with brackets in the property explorer. When it received an invalid input, it just resets it to 0,0.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.