Error Tweening GUI Frame in Game but not in Studio

Hi Developers,

I have a massive issue with my game. I would be most grateful if someone could help me fix it, it might just be as simple as something I can’t see myself!

  1. What do you want to achieve? Tweening a GUI Frame to the centre of the screen.

  2. What is the issue? So, I have done this many times before but this issue has never happened before. The tweening works perfectly fine in Roblox Studio but it completely breaks in the Actual Roblox Game.

  3. What solutions have you tried so far? I have been looking on Google, Youtube, DevForum and Scripting Helpers website but nothing has worked. I could be missing something I guess?

Here is a snippet of my LocalScript run in the client GUI, and server script in ServerScriptService. I am using remote events in ReplicatedStorage, in case you need to know for a potential fix. I have tried moving these to ReplicatedFirst or Workspace but nothing has changed.

LocalScript:

openGuiEvent.OnClientEvent:Connect(function()
	pickBtn.Visible = false
	mainFrame.Visible = true
	-- Tween Position GUI Frame
	mainFrame:TweenPosition(
		UDim2.new(0.5, 0, 0.5, 0),
		"Out",
		"Sine",
		1,
		false
	)
	wait(15)
	mainFrame:TweenPosition(
		UDim2.new(0.5, 0, 2, 0),
		"Out",
		"Sine",
		1,
		false
	)
	pickBtn.Visible = true
end)

ServerScript:

local marketPlaceService = game:GetService("MarketplaceService")
local pickGameID = 1231758142

local openGuiEvent = game.ReplicatedStorage.OpenGuiEvent
local queueEvent = game.ReplicatedStorage.QueueGame
local queue = game.ReplicatedStorage.Queue
local skipQuest = game.ReplicatedStorage.SkipQuest

local function processReceipt(receiptInfo)
	
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if player then
		openGuiEvent:FireClient(player)
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
	
end

marketPlaceService.ProcessReceipt = processReceipt

queueEvent.OnServerEvent:Connect(function(gameNumber)
	queue.Value = gameNumber
end)

Just let me know if there’s anything else that would be more helpful!

Many Thanks as always,
KarateKid147

May you add a video what and how the problem looks like. I dont really know what you mean with completely breaks

1 Like

Games working in studio, but ceasing to work on client are usually caused by elements not being loaded fast enough.
It is hard to say which element is causing the issue, but you can always press F9 on the client to get the error output.
As a wild guess I would suggest to modify your local script a bit (it is the part that you have not provided, so please do not be angry if I’m wrong)

--local script!!!
openGuiEvent = game.ReplicatedStorage:WaitForChild("OpenGuiEvent")
--instead of game.ReplicatedStorage.OpenGuiEvent

Similar to this you should also use WaitForChild for GUI elements that have different ancestor than the script.

1 Like

Hi @Sleazel and @ShyFlooo ,

Thanks for your swift responses.

I’ve combined what @Sleazel said along with some trial and error and it seems to have fixed it.

Once Again, thanks so much!

KarateKid147