Why is this not working?

So I am making an admin system, and I trying to make it so if there are multiple “hints” on the screen at any given time (bar text at the top of the screen), it will put them into a uniform line, I am using tweening so I cannot use UI constraints and so I am using this code here:

if plr.PlayerGui:FindFirstChild("Hints"):FindFirstChild("PrevHint") == nil then
									Hint_2:TweenPosition(UDim2.new(0, 0, 0, 0),"Out","Sine",0.3,false)
								else
									Hint_2:TweenPosition(UDim2.new(0, 0, plr.PlayerGui:FindFirstChild("Hints"):FindFirstChild("PrevHint").Position + UDim2.new(0,0,0.048,0)),"Out","Sine",0.3,false)
								end

Please note that there is more code which would make this work, the reason why I am not showing this is because I used plr.PlayerGui:FindFirstChild("Hints"):FindFirstChild("PrevHint") in a completely different script and it works, that is the source of why it isn’t working I believe, can anyone help me out?

I can post more code if needed.

1 Like

:play() its probably the issue i dont use TweenPosition often so im not sure but make sure to add it

Hint_2:TweenPosition(UDim2.new(0, 0, 0, 0),“Out”,“Sine”,0.3,false):Play()

I do that whenever tweening a part with changing the size or colour for example, but tweening with Guis doesn’t require :play() thanks for your help though.

1 Like

for ur situlation i might use TweenService

local TS = game:GetService("TweenService")

TS:Create(Hint_2,TweenInfo.new(0.3), {Position = Udim2.new(0,0,0,0)}):Play()
1 Like

This problem is plr.PlayerGui:FindFirstChild("Hints"):FindFirstChild("PrevHint") the tweening part works but for some reason it can’t find the hint, yet I have tried it in other scripts and it can find the hint.

1 Like

Check for misspell or The Position in the Gui u might assigned it wrong

1 Like

It might be a simple studio bug considering it works in other scripts, or it might be a misspell or a simple bug.

Have you made sure PrevHint exists? I’d assign it early on as a variable with :WaitForChild().

3 Likes

Yes I have tried checking to see if it is there, both from the server and client side and it is there but the script cannot detect it yet it works with the same code in a different script.

Have you tried this, since you know it exists?

If you are trying to figure out if something does not exist I would suggest using the not statement
Example:
if not plr.PlayerGui:FindFirstChild(“Hints”):FindFirstChild(“PrevHint”) then

1 Like

I have now fixed the error, thank you for everyone’s help, it was because I switched if plr.PlayerGui:FindFirstChild("Hints"):FindFirstChild("PrevHint") == nil then to if prevHint == nil then and I set up a variable called prevHint, but I had the variable in the chatted event so it was reset each time the player chatted.