It’s the equivalent of using wait(), I added this after the version without wait() wasn’t working because I assumed the variable was being set to true or false too fast.
As for the rest of the variables:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Network = ReplicatedStorage:WaitForChild("Network")
local Remotes = Network:WaitForChild("Remotes")
local Player = Players.LocalPlayer
local Data = Player:WaitForChild("Data")
local HUD = script.Parent
-- Container Components
local BuyCreditsContainer = HUD:WaitForChild("BuyCreditsContainer")
local CreditsContainer = HUD:WaitForChild("CreditsContainer")
local ShopContainer = HUD:WaitForChild("ShopContainer")
-- Button Components
local MusicButton = HUD:WaitForChild("MusicButton")
local ShopButton = HUD:WaitForChild("ShopButton")
-- States
local IS_CREDIT_SHOP_OPEN = false
Data.Credits:GetPropertyChangedSignal("Value"):Connect(function()
CreditsContainer.CreditsLabel.Text = Data.Credits.Value .. " Credits"
end)
CreditsContainer.TextButton.Activated:Connect(function()
print"click"
if IS_CREDIT_SHOP_OPEN == false then
BuyCreditsContainer:TweenPosition(UDim2.new(0.163, 0,0.929, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, .7, true)
RunService.Heartbeat:Wait()
IS_CREDIT_SHOP_OPEN = true
print"is open"
elseif IS_CREDIT_SHOP_OPEN == true then
print"should be closing"
BuyCreditsContainer:TweenPosition(UDim2.new(-0.26, 0,0.929, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, .7, true)
RunService.Heartbeat:Wait()
IS_CREDIT_SHOP_OPEN = false
end
end)
There’s no errors. I did add prints to see what portions of the script aren’t being ran. As the original post states it appears that the event itself is only being fired once.
And when you click again, no response. I would make sure the button is still there or the script isn’t freezing somewhere else (Or getting moved or deleted)
I visually confirmed that the button is not being moved and is still visible with nothing overlaying the button. (Checked using explorer in-game after making the frame visible.)
Again, I also explained this in an earlier reply. I added RunService.Heartbeat:Wait() after thinking the variable was being changed too quickly. I’ve tried it without using wait() and it’s still the same problem.
Well. The script itself looks fine. I think it’s an issue elsewhere.
EDIT: I’ve had similar issues with GUIs not running well on large or laggy games. However i’m not sure what your case is.