I made this little script for my shop GUI

Here's my script

-- Inside Local Script
local UILib = require(game.Workspace:FindFirstChild("FadeModule"))
local Cam = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Detector = game.Workspace.Shop
local Head = Player.Character:WaitForChild("Head")
local Blind = Player.PlayerGui:WaitForChild("ShopUX"):FindFirstChild("Blind")
local Container = Player.PlayerGui:WaitForChild("ShopUX"):FindFirstChild("Container")

resetCam = function()
	game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
	game.Workspace.CurrentCamera.CameraType = "Custom"
end

positionCam = coroutine.create(function()
	while wait() do
		Cam.CameraType = Enum.CameraType.Scriptable
		Cam.Focus = game.Workspace.BasePlate.CFrame
		Cam.CoordinateFrame = CFrame.new(0,100,0)
	end
end)

Detector.Touched:connect(function(name)
	name = Player.Name
	game.Workspace:FindFirstChild("shopEvent"):FireServer(Player)
	Player.Character.Torso.Anchored = true
	UILib.Fade(Blind, "In", .1)
	Cam.CameraType = Enum.CameraType.Scriptable
	Cam.Focus = game.Workspace.BasePlate.CFrame
	Cam.CoordinateFrame = CFrame.new(0,100,0)
	wait(2)
	UILib.Fade(Blind, "Out", .1)
	Container.Visible = true
	UILib.Fade(Container, "In", .1)
	coroutine.resume(positionCam)
	UILib.Fade(Container, "Out", .1)
	Container.Visible = false
	resetCam()
end)

I problem here is that I want to reset the cam to our player, but how do i do this ? it seems like the coroutine is blocking me :(

4 comments

0

You really don't want to be using a while loop. Why do you keep setting those properties repeatedly?

0

break

0

corotine.yield stops a coroutine.

0

I'll try to rework on this script