Gui reappears after i die

So I have a main menu and I’m unsure on when I die, why it reappears?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StartJumpingEvent = ReplicatedStorage.Events:WaitForChild("StartJumping")

local Blur = game.Lighting.Blur
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local MainMenuCam = game.Workspace:WaitForChild("MainMenuCam")

local RunService = game:GetService("RunService")

local CameraPart = workspace:WaitForChild("MainMenuCam")
local CurrentCamera = workspace.CurrentCamera

local Mouse = player:GetMouse()

local PlayButton = script.Parent
local GUI = script.Parent.Parent.Parent

local MOVE_SPEED = 150

local TweenService = game:GetService("TweenService")

local textLabel = script.Parent.Parent.Parent.Header -- Get a reference to the TextLabel
local originalRotation = textLabel.Rotation

-- Check if the player has already pressed play
local playerGui = player:WaitForChild("PlayerGui")
local hasPressedPlay = Instance.new("BoolValue")
hasPressedPlay.Name = "HasPressedPlay"
hasPressedPlay.Value = false
hasPressedPlay.Parent = playerGui

if hasPressedPlay.Value then
	return
end

local function UpdateCamera()
	local Center = CameraPart.CFrame
	local MoveVector = Vector3.new((Mouse.X - Center.X)/MOVE_SPEED, (Mouse.Y - Center.Y)/MOVE_SPEED, 0)
	CurrentCamera.CFrame = CameraPart.CFrame * CFrame.Angles(math.rad(-(Mouse.Y - Center.Y)/MOVE_SPEED), math.rad(-(Mouse.X - Center.Y)/MOVE_SPEED), 0)
end

local Connection = RunService.RenderStepped:Connect(UpdateCamera)

PlayButton.Activated:Connect(function()
	Connection:Disconnect()
	StartJumpingEvent:FireServer()
	Blur.Enabled = false
	GUI:Destroy()

	-- Set the HasPressedPlay flag to true
	hasPressedPlay.Value = true
end)

local function rotateLabel()
	while true do
		local rotationGoalRight = {}
		local rotationGoalLeft = {}

		rotationGoalRight.Rotation = math.rad(80) -- Rotate to the right (in radians)
		rotationGoalLeft.Rotation = math.rad(-80) -- Rotate to the left (in radians)

		local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)

		local rotateTweenRight = TweenService:Create(textLabel, tweenInfo, rotationGoalRight)
		local rotateTweenLeft = TweenService:Create(textLabel, tweenInfo, rotationGoalLeft)

		rotateTweenRight:Play()
		rotateTweenRight.Completed:Wait()
		rotateTweenLeft:Play()
		rotateTweenLeft.Completed:Wait()
	end
end

rotateLabel()

Turn off ResetOnRespawn on the ScreenGui.

2 Likes

Thank you so very much, I never even knew that was an option!

1 Like

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