#Shop gui with camera

1 messages · Page 1 of 1 (latest)

mint gale
#

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)

echo talonBOT
#

studio** You are now Level 1! **studio

mint gale
#

-- Close button event: restore camera and hide GUI
closeButton.MouseButton1Click:Connect(function()
print("[Shop] Closing GUI and restoring camera")

restoreCameraToPlayer()
wait(0.1)  -- Retry to counter any interference
restoreCameraToPlayer()

shopFrame.Visible = false
shopGui.Enabled = false

end)

-- On character respawn: restore camera and hide GUI if open
player.CharacterAdded:Connect(function()
wait(0.5)
if shopGui.Enabled and shopFrame.Visible then
print("[Shop] Player respawned, restoring camera and hiding GUI")
restoreCameraToPlayer()
shopFrame.Visible = false
shopGui.Enabled = false
end
end)
second part of script

#

if anyone can help lmk if u need the serverscript or localscipt its js they dont rly have anything to do tiwh the camera so idk

summer reef
#

@mint gale only works once when the character added