I have a randomly generating difficulty chart obby with the general “Reset Button”.
I linked this to ContextActionService
with Enum.KeyCode.R
.
None of my scripts whatsoever mention the Roblox Menu yet when I open it, it triggers the reset functionality.
This is the handler that manages the Reset Button GUI:
local button = script.Parent.Button
button.Visible = game:GetService("UserInputService").TouchEnabled
local player = game.Players.LocalPlayer
local character = player,Character or player.CharacterAdded:Wait()
local function reset()
if not player:GetAttribute("Menu") then --note that menu here means the game's MainMenu
character:PivotTo(CFrame.new(0, 3, 0) * if player:GetAttribute("Stage") == 0 then workspace.Core.Spawn.Spawn:GetPivot() else workspace.Core.Stages[tostring(player:GetAttribute("Stage"))].Checkpoint:GetPivot())
end
character:FindFirstChildOfClass("Humanoid").Health = character:FindFirstChildOfClass("Humanoid").MaxHealth
end
local i = 0
game:GetService("ContextActionService"):BindAction("ResetPlayer", function()
i += 1
if i % 2 == 1 then
reset()
end
end, false, Enum.KeyCode.R)
button.Activated:Connect(reset)
Video of issue: