R6 CFrame camera not being set

Whenever I try to change the camera’s position using CFrame in R6, it doesnt work, meanwhile r15 does. How could I fix this?

can you send the script that’s meant to do it?

1 Like
local playerService = game:GetService("Players")
local lighting = game:GetService("Lighting")
local replicatedStorage = game:GetService("ReplicatedStorage")
local marketPlaceService = game:GetService("MarketplaceService")
local starterGui = game:GetService("StarterGui")
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
local contextActionService = game:GetService("ContextActionService")
local player = playerService.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local screenGui = script:WaitForChild("Lucide")
local remotesFolder = replicatedStorage:WaitForChild("Remotes")
local dwjad215 = remotesFolder:WaitForChild("dwjad215")
local clientRemote = remotesFolder:WaitForChild("client")
local blur = Instance.new("BlurEffect")
local selectedColor = Color3.fromRGB(127, 255, 189)
local trickMod = require(script:WaitForChild("trick"))

blur.Size = 24
blur.Parent = lighting
screenGui.Parent = playerGui
local current = {
	main = nil,
	store = nil,
	team = nil,
}

--// Gui  \\--
local menu = screenGui:WaitForChild("menu")
local mainFrame = menu:WaitForChild("main")
local uiPageLayout = mainFrame:WaitForChild("UIPageLayout")
local top = menu:WaitForChild("topbar"):WaitForChild("pagebuttons")
uiPageLayout.Animated = false
uiPageLayout:JumpTo(uiPageLayout.Parent:WaitForChild("home"))
current.main=top:WaitForChild("home")
current.main.TextColor3 = selectedColor
uiPageLayout.Animated = true


local pageButtons = {
	teams = top:WaitForChild("teams"):WaitForChild("TextButton"),
	store = top:WaitForChild("store"):WaitForChild("TextButton"),
	home = top:WaitForChild("home"):WaitForChild("TextButton"),
	Settings = top:WaitForChild("settings"):WaitForChild("TextButton"),
	credits = top:WaitForChild("credits"):WaitForChild("TextButton")
};

local pages = {
	teams = mainFrame:WaitForChild("teams"),
	store = mainFrame:WaitForChild("shop"),
	home = mainFrame:WaitForChild("home"),
	Settings = mainFrame:WaitForChild("settings"),
	credits = mainFrame:WaitForChild("credits")
};

local homeSettings = pages.home:WaitForChild("settings"):WaitForChild("button")
local homeCredits = pages.home:WaitForChild("credits"):WaitForChild("button")
local homeStore = pages.home:WaitForChild("store"):WaitForChild("button")
local deploy = pages.home:WaitForChild("deploy"):WaitForChild("button")
local storeTop = pages.store:WaitForChild("storetop")
local storeBundlesButton = storeTop:WaitForChild("bundles"):WaitForChild("button")
local storeGamepassButton = storeTop:WaitForChild("gamepasses"):WaitForChild("button")
local storePerksButton = storeTop:WaitForChild("perks"):WaitForChild("button")
local storePages = pages.store:WaitForChild("pages")
local storePerks = storePages:WaitForChild("perks")
local storeGamepass = storePages:WaitForChild("gamepass")
local storeBundles = storePages:WaitForChild("bundles")
local storePageLayout = storePages:WaitForChild("UIPageLayout")

local credFrameFr = pages.credits:WaitForChild("Frame")
local bigStoreButton = pages.store:WaitForChild("Frame"):WaitForChild("Frame"):WaitForChild("button")
local deploydesc = deploy.Parent:WaitForChild("desc")
local loaderFrame = screenGui:WaitForChild("Loader")

--//Extras
local playerTeam = "Mobile Task Force" --get server to send this information
local thumbSize = Enum.ThumbnailSize.Size420x420
local tweenInfo = TweenInfo.new(.2,Enum.EasingStyle.Quad,Enum.EasingDirection.In)
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local defaultcf = workspace:WaitForChild("cameraSpot").CFrame
local scale = 200
local connection:RBXScriptSignal
local gameSounds = {}
local soundConnection
local positions = {
	0.745, --On UDIM2 X Position for settings
	0.255  --Off UDIM2 X Position for settings
}


--//Functions
local function tweenSelected(textlabel)
	tweenService:Create(textlabel,tweenInfo,{TextColor3=selectedColor}):Play()
end

function setGraphics(Setting:bool)
	if Setting then
		lighting.GlobalShadows = true
		if lighting:FindFirstChild("SunRays") then
			lighting.SunRays.Enabled = true
		end
		if lighting:FindFirstChild("Bloom") then
			lighting.Bloom.Enabled = true
		end
	else
		lighting.GlobalShadows = false
		if lighting:FindFirstChild("SunRays") then
			lighting.SunRays.Enabled = false
		end
		if lighting:FindFirstChild("Bloom") then
			lighting.Bloom.Enabled = false
		end
	end
end


local function handleActions(actionName, inputState, inputObject)
	if inputState ~= Enum.UserInputState.Begin then return end

	if actionName == "mPress" then
		if dwjad215:InvokeServer(5623423) == 54 then
			loaderFrame.BackgroundTransparency = 1
			loaderFrame.Visible = true
			local tween = tweenService:Create(loaderFrame,
				TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In),
				{BackgroundTransparency=0})

			tween:Play() 
			tween.Completed:Wait()
			local tween2 = tweenService:Create(loaderFrame,
				TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,1.75),
				{BackgroundTransparency=1}
			)
			game:GetService("Lighting").ClockTime = 6.3

			tween2:Play()
		end
	end
end

clientRemote.OnClientEvent:Connect(function(reason)
	if (reason==1) then
		menu.Visible = true
		blur.Size = 24
		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)
		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
		trickMod:Enable()
		contextActionService:UnbindAction("mPress")

	elseif (reason==2) then
		loaderFrame.BackgroundTransparency = 1
		loaderFrame.Visible = true
		local tween = tweenService:Create(loaderFrame,
			TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In),
			{BackgroundTransparency=0})

		tween:Play()
		tween.Completed:Wait()
		menu.Visible = false
		blur.Size = 0
		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,true)
		trickMod:Disable()
		local tween2 = tweenService:Create(loaderFrame,
			TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,2),
			{BackgroundTransparency=1})
		tween2:Play()
		contextActionService:BindAction("mPress",handleActions,false,Enum.KeyCode.M)
		

	end
end)



local function getButton(page)
	for name,frame in pairs(pages) do
		if frame==page then
			return pageButtons[name]
		end
	end
end

local function openPage(ui,frame,button)
	ui:JumpTo(frame)
end

local function load()
	for _, page in ipairs(storePages:GetChildren()) do
		if page:IsA("Frame") then
			for _, pageFrame in ipairs(page:GetChildren()) do
				if pageFrame:IsA("Frame") then
					local button = pageFrame:WaitForChild("button")
					local id = pageFrame:GetAttribute("gamepassid")
					button.MouseButton1Click:Connect(function()
						marketPlaceService:PromptGamePassPurchase(player,id)
					end)
				end
			end
		end
	end
	for i,v in pairs(pages.credits:WaitForChild("Frame"):GetChildren()) do
		if v:IsA("Frame") then
			local imgLabel = v:WaitForChild("ImageLabel")
			local id = v:GetAttribute("id")
			local content,ready = playerService:GetUserThumbnailAsync(id,Enum.ThumbnailType.AvatarThumbnail,thumbSize)
			if ready then
				imgLabel.Image = content
			else
				imgLabel.Image = "rbxassetid://403653614"
			end
		end
	end
	bigStoreButton.MouseButton1Click:Connect(function()
		local id = bigStoreButton.Parent:GetAttribute("gamepassid")
		marketPlaceService:PromptGamePassPurchase(player,id)
	end)
end

local function frameHandle(first,frame)
	if first == 1 then
		local ts = tweenService:Create(
			frame,
			tweenInfo,
			{BackgroundColor3 = Color3.fromRGB(85,85,85)}
		)
		ts:Play()
	else
		local ts = tweenService:Create(
			frame,
			tweenInfo,
			{BackgroundColor3 = Color3.fromRGB()}
		)
		ts:Play()
	end
end

uiPageLayout:GetPropertyChangedSignal("CurrentPage"):Connect(function()
	local page = uiPageLayout.CurrentPage
	local button = getButton(page)
	if not button then
		return
	end

	if current.main then
		current.main.TextColor3 = Color3.fromRGB(255,255,255) 
	end
	current.main = button.Parent
	tweenSelected(button.Parent)
end)

storePageLayout:GetPropertyChangedSignal("CurrentPage"):Connect(function()
	local page = storePageLayout.CurrentPage
	local button
	if page == storePerks then
		button = storePerksButton.Parent.TextLabel
	elseif page == storeGamepass then
		button = storeGamepassButton.Parent.TextLabel
	elseif page == storeBundles then
		button = storeBundlesButton.Parent.TextLabel
	end
	if not button then
		return
	end

	if current.store then
		current.store.TextColor3 = Color3.fromRGB(255,255,255)
	end
	current.store = button
	tweenSelected(button)
end)



deploy.MouseButton1Click:Connect(function()
	local result = dwjad215:InvokeServer(2318941,playerTeam)
	if result == "success" then
		task.wait(1)
		game:GetService("Lighting").ClockTime = 12 
	end
end)


homeSettings.MouseButton1Click:Connect(function()
	openPage(uiPageLayout,pages.Settings,pageButtons.Settings)
end)
homeCredits.MouseButton1Click:Connect(function()
	openPage(uiPageLayout,pages.credits,pageButtons.credits)
end)
homeStore.MouseButton1Click:Connect(function()
	openPage(uiPageLayout,pages.store,pageButtons.store)
end)
storeBundlesButton.MouseButton1Click:Connect(function()
	openPage(storePageLayout,storeBundles,storeBundlesButton.Parent.TextLabel)
end)
storeGamepassButton.MouseButton1Click:Connect(function()
	openPage(storePageLayout,storeGamepass,storeGamepassButton.Parent.TextLabel)
end)
storePerksButton.MouseButton1Click:Connect(function()
	openPage(storePageLayout,storePerks,storePerksButton.Parent.TextLabel)
end)

function Update()
	-- get the center of the screen
	local Center = Vector2.new(camera.ViewportSize.X/2, camera.ViewportSize.Y/2)
	-- get the movement (it's in studs, and the mouse properties are in pixels, so you want to divide it by your scale to not move the camera really really far)
	local MoveVector = Vector3.new((mouse.X-Center.X)/scale, (mouse.Y-Center.Y)/scale, 0)
	-- CFrame * CFrame makes it work the same regardless of rotation, where addition just makes it work for one direction
	camera.CFrame = defaultcf * CFrame.new(defaultcf.p + MoveVector)
end

local function handleSound(toggle)
	if toggle then
		soundConnection = game.DescendantAdded:Connect(function(descendant)
			if descendant:IsA("Sound") then
				gameSounds[descendant]=descendant.Volume
				descendant.Volume = 0
			end
		end)
		for sound,vol in pairs(gameSounds) do
			sound.Volume = 0
		end
	else
		soundConnection:Disconnect()
		for i,v in pairs(gameSounds) do
			if i.Parent ~= nil then
				i.Volume = v
			else
				gameSounds[i]=nil
			end
		end
	end
end

--Kio2
local settingFunctions = {
	["Low graphics"]=setGraphics,
	["Mute Music"] = handleSound,
}
--Handling
task.spawn(function()
	load()
	for _, frame in ipairs(pages.home:GetChildren()) do
		local button = frame:WaitForChild("button")
		button.MouseEnter:Connect(function()
			frameHandle(1,frame)
		end)
		button.MouseLeave:Connect(function()
			frameHandle(2,frame)
		end)
	end
	storeBundlesButton.MouseEnter:Connect(function()
		frameHandle(1,storeBundlesButton.Parent)
	end)
	for _, frame in ipairs(storeTop:GetChildren()) do
		if frame:IsA("Frame") then
			local button = frame:WaitForChild("button")
			button.MouseEnter:Connect(function()
				frameHandle(1,button.Parent)
			end)
			button.MouseLeave:Connect(function()
				frameHandle(2,button.Parent)
			end)
		end
	end
end)
openPage(storePageLayout,storeGamepass)

for name,button in pairs(pageButtons) do
	button.MouseButton1Click:Connect(function()
		if pages[name] and current ~= button.Parent then
			openPage(uiPageLayout,pages[name],button)
		elseif not pages[name] then
			warn(string.format("%s page was not found",name))
		end
	end)
end
for _, frame in ipairs(pages.teams:WaitForChild("Frame"):GetChildren()) do
	if frame:IsA("Frame") then
		local button = frame:WaitForChild("button")
		local teamSelect = frame:WaitForChild("team")
		local gamepassid = frame:GetAttribute("gamepassid")
		local groupId = frame:GetAttribute("groupId")
		local groupRank = frame:GetAttribute("groupRank")
		if 
			playerTeam == teamSelect.Text then
			current.team = teamSelect
			tweenSelected(teamSelect)
			deploydesc.Text = "Spawn as: "..playerTeam
		end
		local desc2 = ""
		local pricelabel = frame:WaitForChild("price")
		if gamepassid == 0 then
			desc2 = "FREE"
		elseif gamepassid ~= 0 then
			if marketPlaceService:UserOwnsGamePassAsync(player.UserId,gamepassid) then
				desc2="OWNED"
			else
				local price = marketPlaceService:GetProductInfo(gamepassid,Enum.InfoType.GamePass).PriceInRobux
				desc2="$"..price
			end
			
		end
		pricelabel.Text = desc2
		button.MouseButton1Click:Connect(function()
			if current.team == teamSelect then return end
			if teamSelect.Text == "???" then return end
			if gamepassid ~= 0 then
				if not marketPlaceService:UserOwnsGamePassAsync(player.UserId,gamepassid) then
					marketPlaceService:PromptGamePassPurchase(player,gamepassid)
					return
				end
			end
			if groupId ~= 0 then

				if not (player:GetRankInGroup(groupId) >= groupRank) then
					return
				end
			end
			if current.team then
				current.team.TextColor3 = Color3.fromRGB(255,255,255)
			end
			current.team = teamSelect
			tweenSelected(teamSelect)
			playerTeam = teamSelect.Text
			deploydesc.Text = "Spawn as: "..playerTeam
		end)
		button.MouseEnter:Connect(function()
			if teamSelect.Text ~= "???" then
				frameHandle(1,teamSelect.Parent)
			end
		end)
		button.MouseLeave:Connect(function()
			if teamSelect.Text ~= "???" then
				frameHandle(2, teamSelect.Parent)
			end
		end)
	end
end
for _, directionFrame in ipairs(pages.Settings:GetChildren()) do
	for _, frame in ipairs(directionFrame:WaitForChild("Frame"):GetChildren()) do
		if frame:IsA("Frame") then
			local button = frame:WaitForChild("button")
			local visualButton:Frame = frame:WaitForChild("Frame"):WaitForChild("Frame")
			local toggled = frame:WaitForChild("toggled")
			local uistroke = visualButton.Parent:WaitForChild("UIStroke")
			local sname = frame:WaitForChild("sname").Text
			button.MouseButton1Click:Connect(function()
				if toggled.Value == true then
					--turn the setting off
					toggled.Value = false
					visualButton:TweenPosition(
						UDim2.new(positions[2],0,visualButton.Position.Y.Scale,0),
						Enum.EasingDirection.In,
						Enum.EasingStyle.Sine,
						.2,
						true
					)
					visualButton.BackgroundColor3 = Color3.fromRGB(170, 93, 93)
					visualButton.Parent.BackgroundColor3 = Color3.fromRGB(170, 93, 93)
					uistroke.Color = Color3.fromRGB(170, 93, 93)

					if settingFunctions[sname] then
						settingFunctions[sname](toggled.Value)
					end
				else
					--turn the setting off
					toggled.Value = true
					visualButton:TweenPosition(
						UDim2.new(positions[1],0,visualButton.Position.Y.Scale,0),
						Enum.EasingDirection.Out,
						Enum.EasingStyle.Sine,
						.2,
						true
					)
					visualButton.BackgroundColor3 = Color3.fromRGB(85, 170, 127)
					visualButton.Parent.BackgroundColor3 = Color3.fromRGB(85, 170, 127)
					uistroke.Color = Color3.fromRGB(85, 170, 127)

					if settingFunctions[sname] then
						settingFunctions[sname](toggled.Value)
					end
				end
			end)
			button.MouseEnter:Connect(function()
				frameHandle(1,frame)
			end)
			button.MouseLeave:Connect(function()
				frameHandle(2,frame)
			end)
		end
	end
end

game.DescendantRemoving:Connect(function(descendant)
	if descendant:IsA("Sound")then
		if gameSounds[descendant] then
			gameSounds[descendant]=nil
		end
	end
end)

marketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player,gamepassId,purchased)
	if not purchased then return end
	for i,v in pairs(pages.teams:WaitForChild("Frame"):GetChildren()) do
		if v:IsA("Frame") then
			local id = v:GetAttribute("gamepassid")
			if id == gamepassId then
				if current.team then
					current.team.TextColor3 = Color3.fromRGB(255,255,255)
				end
				current.team = v.team
				tweenSelected(v.team)
				playerTeam = v.team.Text
				deploydesc.Text = "Spawn as: "..playerTeam
				local pricelabel = v:WaitForChild("price")
				pricelabel.Text = "OWNED"
				break
				
			end
		end
	end
end)

for i,v in pairs(game:GetDescendants()) do
	if v:IsA("Sound") then
		gameSounds[v]=v.Volume
	end
end
2 Likes