Problem with if then statement and position

Hello, if you already saw the titel then you maybe know what my problem is so i come here to ask you!

So in my game, there is only gui’s and you have to script a lot and I’m not that good at it so sorry if this is a stupid mistake. Right now I’m making a script using the “if then” statement to change a position of a gui but it’s not working.

This is the script I use:


script.Parent.MouseButton1Click:Connect(function()
	print("Button activated!")
	if script.Parent == UDim2.new(0.046, 0, 0.041, 0) then
		print("Checked!!")
		script.Parent.Position = UDim2.new(0.033, 0, 0.676, 0)
		print("Position Changed!")
	end
end)

If I test this it only prints “Button activated!” so I think something is wrong with the
“if then” statement but I can’t figure out what :confused:

Can someone maybe help me and say what I did wrong?

Thank you for taking time to this and hopefully helping me :grin:

you’re just asking if script.Parent == an UDIM value try script.Parent.Position

if script.Parent.Position == UDim2.new(0.046, 0, 0.041, 0)
not
if script.Parent == UDim2.new(0.046, 0, 0.041, 0)
1 Like

try

script.Parent.DarkGameFinder.MouseButton1Click:Connect(function()
	print("Button activated!")
	if script.Parent.Position == UDim2.new(0.046, 0, 0.041, 0) then
		print("Checked!!")
		script.Parent.Position = UDim2.new(0.033, 0, 0.676, 0)
		print("Position Changed!")
	end
end)

2 Likes