hey so im trying to make a shop gui that moves yoru camera to a part but no matter what i do it will NOT reset when close button is pressed the gui closed but the csamer dosent reset
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local shopGui = script.Parent -- This LocalScript must be inside your ScreenGui (MyGui)
local shopFrame = shopGui:WaitForChild("ShopFrame")
local closeButton = shopFrame:WaitForChild("CloseButton")
local remote = ReplicatedStorage:WaitForChild("ShowGuiEvent")
local cameraTarget = workspace:WaitForChild("Camera1")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
-- Function to restore camera to player
local function restoreCameraToPlayer()
local char = player.Character
if not char then return end
local cam = workspace.CurrentCamera
local humanoid = char:FindFirstChildOfClass("Humanoid")
if humanoid then
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = humanoid
else
-- fallback to HumanoidRootPart or Torso if no humanoid found
local rootPart = char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso")
if rootPart then
cam.CameraType = Enum.CameraType.Attach
cam.CameraSubject = rootPart
end
end
print("[Camera] Restored to player")
end
remote.OnClientEvent:Connect(function()
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
print("[Shop] Opening GUI and moving camera")
shopGui.Enabled = true
shopFrame.Visible = true
camera.CameraType = Enum.CameraType.Scriptable
local tween = TweenService:Create(camera, tweenInfo, {CFrame = cameraTarget.CFrame})
tween:Play()
end)
** You are now Level 1! **