Why wont this work?

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Parent.popup:TweenPosition(UDim2.new(0, 0, 0.074, 0), “Out”, “Quad”, 0.7, true)
task.wait(0.7)
script.Parent.Parent.Parent.Parent.popup.Visible = false
end)

when a button (in this case the X button) is clicked then the ui smoothly tweens down and then becomes invisible once done, yet it gives me an error in the output saying " 23:06:37.430 Unable to cast value to function - Client - LocalScript:4", is this cause of roblox being down or my bad scripting skills?

4 Likes

Its nothing to with scripting skills just a common mistake we all make. Just remember next time if you going to put words in a string use “” or ‘’, not “”.

Here you go:

script.Parent.Parent.Parent.Parent.popup:TweenPosition(UDim2.new(0, 0, 0.074, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.7, true)

Enums are better than using the old string way. Hope this helps :slight_smile:

4 Likes
nope, same issue sadly, it only does the .visible = false part, idk why
2 Likes

Oh i see, well i have no clue. Could you send me the code in format?

1 Like

ill send the screen shots with the info needed

1 Like

image
the popup is a frame that controls the tweening, the textbutton inside credits is the X button, the credits has a script which i will tell u in a second, the credits frame is the actual thing we tween

the script for the credits button:
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.popup.Visible = true
script.Parent.Parent.popup:TweenPosition(UDim2.new(0, 0, 0.074, 0), “In”, “Quart”, 0.7, true)
task.wait(0.7)
script.Parent.Visible = false
script.Parent.Parent.pla.Visible = false
end)

(it works btw)

In the first message you put you have more then 2 Parents before popup, maybe thats why? Other than i have no idea.

i had the same issue today while tweening but then it just got fixed when i retyped it (but without variables), i do not know why that fixed it, and thats also the reason the scripts look unorganized with all the .parents

ok good to hear, but next time if you going to post a script on the dev forum and you want people to help you fix it, put ``` before the code and the same after it, makes it easier to read.

thanks ive been trying to figure out how to do that n im new to this place lol

OH MY GOD I FIGURED IT OUT ITS CAUSE IPUT THE WRONG POSITION IN :sob:

1 Like

Mark this as the solution so this post gets closed.

1 Like
ok

oh haha, well im happy to hear its all right now! :slight_smile:

1 Like

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