The problem: The variable canClick is my guess as to why it doesn’t work. It probably isn’t getting set to true
Organization: Your code is very unorganized and repetitive.
All of those lines take up a lot of space and are hard to follow. Creating a variable for each on would be much more effective.
local button = script.Parent.Roll
local cooldown = script.Parent.Cooldown
local rng_function = game.ReplicatedStorage.Functions.RNG
local reward_text = script.Parent.RollFrame.RewardContainer.RewardText
local reward_chance = script.Parent.RollFrame.RewardContainer.RewardChance
local rollframe = script.Parent.RollFrame
local start_cooldown = game.ReplicatedStorage.Functions.CooldownStart
button.MouseButton1Click:Connect(function()
if not canClick then return end
ButtonTween:Play()
canClick = false
local fakeRewards, reward = rng_function:Invoke()
cooldown.Visible = true
reward_text.Text = reward[1]
reward_chance.Text = '1 in '..tostring(reward[2])
rollframe.Visible = true
start_cooldown:Invoke()
print("Cooldown")
task.wait(2)
ButtonTween1:Play()
task.wait(1)
rollframe.Visible = false
cooldown.Visible = false
canClick = true
end)
Back to the actual issue, for more assistance I will need to see what causes the canClick variable to change. If it starts as false then the button can’t ever be clicked.