Hello!
I’m currently working on a custom stage selector for an obby game. It allows you to navigate through the stages you have already completed.
However, the MouseButton1Click
event for the button (which allows you to go back to a stage) isn’t firing when it’s supposed to. No matter how many times I click the button, the statement that indicates whether the button has been clicked never prints.
Here’s the code, located in a LocalScript
inside the button:
local Players = game:GetService("Players")
local button = script.Parent
local number = script.Parent.Parent.Parent.INT
local player = Players.LocalPlayer
local stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
local checkpointsFolder = workspace:WaitForChild("CHECKPOINTS")
local maxStages = 13
button.MouseButton1Click:Connect(function()
print("The button was clicked.") -- This statement doesn't print.
if number.Value > 1 then
number.Value = number.Value - 1
if player then
if player.Character then
local character = player.Character
if character:FindFirstChild("Humanoid") then
if character:FindFirstChild("HumanoidRootPart") then
local hrp = character.HumanoidRootPart
hrp.CFrame = checkpointsFolder:FindFirstChild(number.Value).CFrame + Vector3.new(0,3,0)
end
end
end
end
end
end)
Nothing, not even errors or warnings about the code, print in the output. I’m genuinely confused since this was working before. The event only stopped firing yesterday, and I don’t know why.
I’ve tried replacing the MouseButton1Click
event with the Activated
event, but I got the same result. I also tried to find a topic on the DevForum that would help, but all of the solutions mention the ZIndex
. I’m almost certain that this isn’t the source of the issue because the ZIndex
of the button is greater than any other UI element in the ScreenGui
I have.
If you have any idea as to why the event isn’t firing properly, please reply below.
Thank you.
Edit: I realized that no matter where I place the button in the ScreenGui
, if they’re touching a certain TextLabel
, the event won’t fire. Weird.