Script works only once for some reason

  1. What do you want to achieve? Keep it simple and clear!
    I wanna my script open a GUI, when i use it first time GUI opens, but when i use it again it do nothing

  2. What is the issue? Include screenshots / videos if possible!
    image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Everything must works fine idk what is problem

local TweenService = game:GetService("TweenService")
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr then
			if not plr.PlayerGui:FindFirstChild("GUIClonedfromtouchblock") then
				plr.PlayerGui.TraderGui.DialogueFrame.Visible = true
				plr.PlayerGui.TraderGui.DialogueFrame:TweenSize(
					UDim2.new(0.9, 0,0.2, 0),
					Enum.EasingDirection.Out,
					Enum.EasingStyle.Bounce,
					true,
					0.5
				)
			end
		end
	end
end)

2 Likes
local TweenService = game:GetService("TweenService")

local debounce = false

script.Parent.Touched:Connect(function(hit)
if not debounce then
	if hit.Parent:FindFirstChild("Humanoid") then
        debounce = true
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr then
			if not plr.PlayerGui:FindFirstChild("GUIClonedfromtouchblock") then
				plr.PlayerGui.TraderGui.DialogueFrame.Visible = true
				plr.PlayerGui.TraderGui.DialogueFrame:TweenSize(
					UDim2.new(0.9, 0,0.2, 0),
					Enum.EasingDirection.Out,
					Enum.EasingStyle.Bounce,
					true,
					0.5
				)
                debounce = false
			end
		end
	end
else
-- REVERSE TWEEN HERE
end
end)

Oops sorry i posted wrong script here is normal:

local Text = script.Parent
local AnimateUI = require(game.ReplicatedStorage:WaitForChild("AnimateUI"))
local TextMessage1 = "Huh? So you wanna change your clicks into money?"
local TextMessage2 = "Okay, then let's trade! Remember 10 clicks = 1$"
local TradeButton = script.Parent.Parent.TradeButton
local SecretButton = script.Parent.Parent.SecretButton
local GUI = script.Parent.Parent
local function Message1()
wait(0.4)
		AnimateUI.typeWrite(Text,TextMessage1,0.05)
end
local function Message2()
	TradeButton.Visible = false
	SecretButton.Visible = false
	AnimateUI.typeWrite(Text,TextMessage2,0.05)
	wait(1)
	GUI:TweenSize(
		UDim2.new(0.9, 0,0, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Bounce,
		true,
		0.5
	)
	GUI.Visible = false
	
end
GUI.Changed:Connect(function()
if GUI.Visible == true then
	Message1()
	end
	end)
TradeButton.MouseButton1Click:Connect(function()
		Message2()
end)

you need to enable the .Visible property of the ui cuz i see youre only disabling it in function Message2(),
also, this wont work:

do Gui:GetPropertyChangedSignal("Visible")

I enable it in other function, + it works

which one?

itll listen to other properties so its better just to do it on visible

In other script

local TweenService = game:GetService("TweenService")

local debounce = false

script.Parent.Touched:Connect(function(hit)
	if not debounce then
		if hit.Parent:FindFirstChild("Humanoid") then
			debounce = true
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			if plr then
				if not plr.PlayerGui:FindFirstChild("GUIClonedfromtouchblock") then
					plr.PlayerGui.TraderGui.DialogueFrame.Visible = true
					plr.PlayerGui.TraderGui.DialogueFrame:TweenSize(
						UDim2.new(0.9, 0,0.2, 0),
						Enum.EasingDirection.Out,
						Enum.EasingStyle.Bounce,
						true,
						0.5
					)
					debounce = false
				end
			end
		end
		end
		end)	

Still can’t figure a problem it just do nothing

Fixed a problem myself just used fire client