Players.ZensStarz.PlayerGui.TheMeditations.BallRandommovement:36: invalid argument #3 (Vector2 expected, got UDim2)

At the current moment, the only way my script will activate through making the function activate only when the game acknowledges that the mouse is on the AbsolutePosition, not the actual Circle position, so I tried to figure out how to make the Anchor point the actual position of the circle, and it failed. Ending in this error.

  01:24:57.516  Players.ZensStarz.PlayerGui.TheMeditations.BallRandommovement:36: invalid argument #3 (Vector2 expected, got UDim2)

So, here’s the script, and the methods I have tried vary from:

Making the Circle its own individual thing in the explorer,

Making the Circle be in its own separate GUI

Trying to change the AbsoluteSize,

and none of them worked so here I am.

Here’s the script:

-- \\ Variables // --

local Randomzier = Random.new()

local Meditation = Instance.new("BoolValue")

local GUIS = script.Parent

local Circle = GUIS.MovingCircle

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local Mouse = Player:GetMouse()

-- \\ Services/Service-Related Variables // --

local UIS = game:GetService("UserInputService")

local RS = game:GetService("RunService")

local MLocation = UIS:GetMouseLocation(Mouse.Hit)

-- \\ Functions // --

GUIS.IgnoreGuiInset = true

local function GetGone()
	
	local position = UDim2.new(0,Mouse.X,0,Mouse.Y) 
	
	--print(position)
	--print(Circle.Position)
	--print(Circle.AbsolutePosition)
	Circle.AnchorPoint = Circle.Position
	
	if position == Circle.Position then
		print("On the circle..")
		repeat 
		script.Parent.MovingCircle:TweenPosition(
			UDim2.new(Randomzier:NextNumber(0.962, 0),0 ,Randomzier:NextNumber(0.285, 0),0),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Linear,
			5,
			false,
			nil

			)
		until
		UIS:GetMouseLocation() ~= script.Parent.MovingCircle.Position 
		
	else
	end
end

RS:BindToRenderStep("GetGone", 1, GetGone)

The immediate error is that there’s no translation between AnchorPoint and Circle.Position. If you want a circle to be centered on a location, make its AnchorPoint = Vector2.new(0.5,0.5) and Position where you want it. I don’t quite understand the application so I can’t think of further fixes. What is the circle doing in your game? How’s the player interact with it?

1 Like

Yea I was confused by this as well I only really overlooked it. Only wishing that roblox puts line numbers on the code blocks

1 Like

Right. Exact error is

Circle.AnchorPoint = Circle.Position

Ah, I’m sorry. Basically, the function of the ball is to move around in random positions once the mouse is on the ball, which is only achieved if I make the mouse be equal to the AbsolutePosition of the GUI. So, I tried to make the anchor point be focused on the actual circle because I believed that would make the Position be equal to the actual circle on the screen.

Fixed it by myself. I was going about wrong the whole time. Needed a whole different function.