GUI Tween not playing twice

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Bring the Shop UI down using tweens then bring it back up

  2. What is the issue? Include screenshots / videos if possible!
    The tween won’t seem to work a third time
    gui error - YouTube

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I changed an activated boolean on the gui to check if it’s activated or not to be changed locally so i used remote events (server to client) and that helped with the boolean

Code for the prompt

local prompt = script.Parent


prompt.Triggered:Connect(function(plr)


local platform = plr.PlayerPlatform

	
if platform.Value == "PC" then
		print("a")
		local ui =  plr.PlayerGui.PC
		local shop = ui.ImageLabel
		local tweenservice = game:GetService("TweenService")
		local goals = {}
		goals.Position = UDim2.new(0.161, 0,0.142, 0)
		local info = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
		local tween = tweenservice:Create(shop,info,goals)
		local actived = shop.Activated
			if not actived.Value then
				tween:Play()
				print(shop.Position)
				print("fired this thing")
				game.ReplicatedStorage.RemoteEvents.changeactivatedvaluepc:FireClient(plr)
			end
				
			


	
--[[elseif platform.Value == "Console" then

local ui =  plr.PlayerGui.CONSOLE
local shop = ui.ImageLabel
local tweenservice = game:GetService("TweenService")
local goals = {}
goals.Position = UDim2.new(0.161, 0,0.142, 0)
local info = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local tween = tweenservice:Create(shop,info,goals)
local actived = shop.Activated
if not actived.Value then
	actived.Value = true
	tween:Play()
else

end

	
elseif platform.Value == "Mobile" then
	
local ui =  plr.PlayerGui.MOBILE
local shop = ui.ImageLabel
local tweenservice = game:GetService("TweenService")
local goals = {}
goals.Position = UDim2.new(0.138, 0,0.131, 0)
local info = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local tween = tweenservice:Create(shop,info,goals)
local actived = shop.Activated
if not actived.Value then
	actived.Value = true
	tween:Play()
else

end]]--
		
	end
end)

mobile and console are commented for testing

Code for the x button

local button = script.Parent
local shop = button.Parent
local tweenservice = game:GetService("TweenService")
local goals = {}
goals.Position = UDim2.new(0.161, 0,-2, 0) 
local info = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local tween = tweenservice:Create(shop,info,goals)
local actived = shop.Activated
print(actived.Value)
button.Activated:Connect(function()
	if actived.Value then
		print(actived.Value)
		tween:Play()
		print(shop.Position)
		actived.Value = false
	end
end)

Code from the local script

game.ReplicatedStorage.RemoteEvents.changeactivatedvaluepc.OnClientEvent:Connect(function()
	print(game.Players.LocalPlayer.PlayerGui.PC.ImageLabel.Activated.Value)
	game.Players.LocalPlayer.PlayerGui.PC.ImageLabel.Activated.Value = true
	print(game.Players.LocalPlayer.PlayerGui.PC.ImageLabel.Activated.Value)
	print("didt eh thing")
end)
1 Like

I fixed it by putting the tween inside the local script

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