Properly Tweening a UI

For those who are complaining that I'm making too much posts today

I’m trying to make a proper game as a solo dev.

Hey everyone! So I’m making a game which includes tweening but nothing shows up in output. Here’s the hierarchy:
SpeedrunnerHeirarchy
(In the file name I misspelled)
The local script inside the screen gui:

local secondCount
game.ReplicatedStorage.TweenDetails.OnServerEvent:Connect(function()
local player = game.Players.LocalPlayer
script.Parent.Parent = game.StarterGui
game.ReplicatedStorage.TweeningEvent:FireClient(player)
end)

and the script inside the starter gui:

local tweenService = game:GetService("TweenService")
game.ReplicatedStorage.TweeningEvent.OnClientEvent:Connect(function()
	local frame = script.Parent.ScreenGui:WaitForChild("Frame")
	if frame then
		local table = {}
		table.Position = UDim2{0.5, 0.5}
		local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0)
		local tween = tweenService:Create(frame, tweenInfo, table)
		tween:Play()
	end
end)

Thanks for the help!
(Please tell me if anything is outdated, I got this from the API)

1 Like

Why are you using WaitForChild then after checking if it exists. WaitForChild yields until the thing you are looking for is found!

Also why is there a gui inside of ServerStorage, not only do scripts not run in ServerStorage but only the server can see what is inside of ServerStorage.

Guis need to be in StarterGui!

(Exception to the above: You don’t want to show the gui yet, therefore storing it in serverstorage to optimize network traffic for later use)

1 Like

??? I do not understand this. I set the parent of the gui to starter gui in the 1st code I put above.
Wait it doesn’t run in server storage? So I should put it in replicated storage?

1 Like

If you actually don’t want the code to run yet then ServerStorage is fine, but the player cannot access ServerStorage.
And you never parented any gui to StarterGui with code because:

local secondCount
game.ReplicatedStorage.TweenDetails.OnServerEvent:Connect(function()
local player = game.Players.LocalPlayer
script.Parent.Parent = game.StarterGui --This actually tries to parent the DataModel to startergui.
game.ReplicatedStorage.TweeningEvent:FireClient(player)
end)
1 Like

@hurzell Okay, so what I have to do is put the gui in replicated storage so every client can have it, and turn the local script to a normal script?

1 Like

I am really unsure what you mean because there is a lack of details in the post but.
Localscripts will only run if it is a descendant of one of the player script containers:

Localscripts will not run inside of ReplicatedStorage or ServerStorage.

So how do I correctly parent the gui to starter gui

1 Like

Do you want everyone to be able to see it, or should only a select few be able to?

1 Like

Everyone in the server, after they complete an obstacle course. Here’s the game file (I’m doing the important parts first before the course)
Speedrunners (ALPHA).rbxl (33.6 KB)

1 Like

I will create a working example for you because i am not great at explaining, give me a minute!

2 Likes

Sorry it took so long, i had to do quite a bit of restructuring.
Speedrunners (ALPHA).rbxl (32.5 KB)

This simply shows text on the screen when you touch the part. Feel free to analyze the code to figure out how i did this, but, in simple terms:

When the player touches the part, a RemoteEvent is fired and the gui tweens text on to the screen. It is that simple!

(Please do not use the code in here as it is, it is not meant for production but more the less acts as a showcase)

I don’t really need the cooldown, but it still won’t work, even after putting it in starter gui and turning of visible (I enabled it in the script)

1 Like

That place file works without making any changes, and the cooldown isn’t meant to be on the client but i was in a bit of a rush. That should always be on the server. Touch can fire loads of times for one part, hence i added some form of cooldown.

Oh no after turning the easing style to quint it’s giving me an error I fixed earlier. When trying to teleport from the lobby, it says I’m not a player object, even after debugging

1 Like

I already added a form of debounce (bool) but it still isn’t showing. Can you, uh, edit the place but WITH the frame so I can see what to do?

The dev forum isn’t really a place for people to write code for you, i only did because it helped me explain. And even more so i mentioned

(Please do not use the code in here as it is, it is not meant for production but more the less acts as a showcase)

You aren’t meant to USE the code in the place file in an actual project, it contains explanations in the form of comments and shows how you can use tweenservice and more, it isn’t production ready.

(Also the reason lots of things are missing is because lots of those things weren’t necessary to have)

1 Like

It isn’t working, even though I made sure that the code was somewhat like yours (the tweening)

I need more information than that, can you show me the code you wrote?

1 Like
local tweenService = game:GetService("TweenService")
game.ReplicatedStorage.TweeningEvent.OnClientEvent:Connect(function()
	local frame = script.Parent.Frame
	frame.Visible = true
	local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, true, 0)
	local tween = tweenService:Create(frame, tweenInfo, {Position = UDim2.fromScale(.5, .5)})
	tween:Play()
	wait(5)
	frame.Visible = false
end)

Here it is. I changed the easing style to quint in the hopes of it working.

I changed the easing style to quint in the hopes of it working.

All changing the easing style will do is change how the animation looks, or as it’s names, how it eases into the properties you gave it.

I unfortunately have to leave because i have things i need to do, but remember that Localscripts will only run if they are descendants of player containers, which means StarterGui, StarterScripts, a players character or StarterPack

1 Like