Why does my UI Go to 0,0,0,0?

Hi Other Developers,

I set in my code for a UI to move to a position and then move it to its original spot using TweenService, Sort of like it slides into place. This was done in a ServerScript and the bug is the UI stays in the top left corner.

Here is my script:

local TweenService = game:GetService("TweenService")
local MoveShopInfo = TweenInfo.new(0.6, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false)
local sensor = script.Parent
local debound = false

sensor.Touched:Connect(function(hit)
	if not debound and hit.Parent:FindFirstChild("Humanoid") ~= nil then
		debound = true

		--// Varibles
		local Character = hit.Parent
		local Player = game.Players:FindFirstChild(Character.Name)
		local PlayerGui = Player.PlayerGui
		local GemShop = PlayerGui.GemShop
		local Buttons = PlayerGui.Buttons
		local ReferenceUI = PlayerGui.ReferenceGUI
		local Clicks = PlayerGui.Clicks

		local GemShopFrame = GemShop.GemShopBG
         --Setting the Old position
		local GemShopOldPos = UDim2.new({0.252, 0},{0.166, 0})
		print(GemShopFrame.Position)

		--// Disabling GUIS
		Buttons.Enabled = false
		Clicks.Enabled = false
		ReferenceUI.Enabled = false

		--// GemShop MoveIntoPlace Animation
		print("Played")
		GemShop.Enabled = true
		GemShopFrame.Position = UDim2.new({0.252, 0},{1, 0})
		TweenService:Create(GemShopFrame, MoveShopInfo, {Position = GemShopOldPos}):Play() -- Plays the Animation

		wait(0.6)
		debound = false

	end
end)

sensor.TouchEnded:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then

		debound = false

		--// Variables
		local Character = hit.Parent
		local Player = game.Players:FindFirstChild(Character.Name)
		local PlayerGui = Player.PlayerGui
		local GemShop = PlayerGui.GemShop
		local ReferenceUI = PlayerGui.ReferenceGUI		
		local Buttons = PlayerGui.Buttons
		local Clicks = PlayerGui.Clicks

		--// Disabling/Enabling GUIS
		Buttons.Enabled = true
		Clicks.Enabled = true		
		ReferenceUI.Enabled = true
		GemShop.Enabled = false
	end
end)

Thanks a lot!

In the instances where you use UDim2.new you do not need to use the curly braces, just 4 numbers seperated by commas, like so

Udim2.new(0.252, 0, 0.166, 0)
1 Like

oh i see thanks, i didnt know that curly braces would break it because i only copy and pasted xd

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