UI not appearing the second time

Hey, I am having a bug where my UI does appear the first time, then after I close it and reposition it it doesnt work anymore. I debugged it and frame still prints, the tweening just isnt working the second time.

Code for UI to appear and position (server script) :

local players = game:GetService("Players")

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		print("hit")
		local player = players:GetPlayerFromCharacter(hit.Parent)
		
		local frame = player.PlayerGui.MainGui.MainFrame.MatchMakingFrame
		frame.Visible = true
		frame:TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back,0.5)
	end
end)

Code to close and reposition UI (local script) :

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Searching.Value = false
	script.Parent.Parent.Parent:TweenPosition(UDim2.new(0.5,0,-0.5,0),Enum.EasingDirection.In,Enum.EasingStyle.Back,0.5)
	wait(0.6)
	script.Parent.Parent.Parent.Visible = false
end)

Let me know.

Hey, can you do me a favor and record what happens on ROBLOX studio? Also, are you sure about the “script.Parent.MouseButton1Click” part is the button you want to be clicked to close it?

Use a remote event on the ui local script. I’ve had the same problem before.

1 Like

Yeah, adding on to what he said. Use a remote event. In the server script, you can fire the remote event, and then on the local script do EventName.OnClientEvent.

https://gyazo.com/06520660a23fe3c1f20666665756c475

Dude, fire a remote event from the client handle it with the server and in teh OnServerEvent script tween the gui object.

1 Like