MouseButton1Click not working

Hi I am trying to tween a airplane seat and I want to tween it by pressing a textbutton. But it’s not working. When i press nothing happens. No Errors.

Here is my Code.

script.Parent.Parent.Seat.Script.GuiS.TextButton.MouseButton1Click:Connect(function()
	local TweenService = game:GetService("TweenService")

	local visible = script.Parent.Parent["Seat"]
	local invisible = script.Parent["Seat"]

	local goal = {}
	goal.Position = invisible.Position
	goal.Orientation = invisible.Orientation

	local tweenInfo = TweenInfo.new(5)

	local tween = TweenService:Create(visible, tweenInfo, goal)
	tween:Play()
end)
6 Likes

On line 5 it looks like your forgetting a “Parent”

1 Like

You should probably wait for the tween to end so it’s not spammed.

As well you can add a print() to check if it works.

It probably works but the issue that it plays multiple times etc.

Try it and reply with the results.

1 Like

Maybe this would work?

script.Parent.Parent:WaitForChild("Seat"):WaitForChild("Script"):WaitForChild("GuiS"):WaitForChild("TextButton").MouseButton1Click:Connect(function()
	print("Button was clicked!")
	local tween = game:GetService("TweenService"):Create(script.Parent.Parent["Seat"], TweenInfo.new(5), {CFrame = script.Parent["Seat"].CFrame})
	tween:Play()
end)
1 Like

do you have any console print?

2 Likes

Nope it doesn’t BlockHead Robloxtim2001

3 Likes

Damn, well in that case it means everything inside the function is correct just not the function itself (if you know what I mean)

edit: You could try printing the name of the seat to see if it shows an error or nil

1 Like

Nope it doesn’t print anything related to that code

  18:16:10.791  Classic Baseplate auto-recovery file was created  -  Studio
  18:16:12.708  Waited.  -  Server
  18:16:14.215  Waited.  -  Client
  18:16:15.035  Requiring asset 6738245247.
Callstack:
cloud_2971874773.Atmos.PluginUpdates, line 36
cloud_2971874773.Atmos.PluginUpdates, line 35 - getLatestVersion
cloud_2971874773.Atmos.Script, line 322
  -  Server
  18:16:15.718  [TCH] You aren't in team create yet! Enable team create so Team Create Hats can function properly.  -  Server
  18:16:17.218  [TCH] You aren't in team create yet! Enable team create so Team Create Hats can function properly.  -  Client
1 Like

first of all use variables and make your code not look like a total mess
script.parent.parent is not good,
make variables for everything

1 Like

No, I mean that you might be seeing if Nil was clicked
Print the name to see if its nil

1 Like

That is not the problem. But I am a bit messy. When i tested the code without the mousebutton1click function it worked.

1 Like

try without orientation its should work

1 Like

With my code I removed that… replacing it with CFrame

1 Like

its a gui dude gui doesnt have cframe method

1 Like

is the seat a frame?! damn… didn’t know

1 Like

ow sorry man really im sorry i didn’t see that

1 Like

Anyways, now try removing everything again inside the function and seeing if it works (don’t remove the print)

1 Like

It still doesn’t work. I put the script inside a folder maybe that is causing a problem?

2 Likes

Why is the ScreenGui inside a script?

1 Like

It’s a script that enables a gui when a player sits on it