CFrame is pissing me off dude

hey.

so i made a previous post about CFrame about 3 days ago, and I tried all of the solutions, and they worked perfect.

so i tried the solutions again, so that the player could exit out of the area he is in, and make it look like he is walking up the place he had came from.

unfortunately, thats not the case.

here is the video:

here is the code:

local plr = game:GetService('Players').LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local cam = require(plr.PlayerScripts.Player.PlayerCamera.Handler)
local cammain = plr.PlayerScripts.Player.PlayerCamera
local plrgui = plr.PlayerGui
local hud = plrgui:WaitForChild('UIHud')
local controls = require(plr.PlayerScripts.ControlScript.Handler)

local typewriter = require(game:GetService('ReplicatedStorage').Typewriting.Typewriter)
local ts = game:GetService('TweenService')
local musichandle = require(plr.PlayerScripts.Player.Music)

local hrp = chr:WaitForChild('HumanoidRootPart')
local hum = chr:WaitForChild('Humanoid')

local swordareas = {
	SwordArea1 = 'SwordArea1',
	SwordArea1Exit = 'ExitSwordArea1'
}

local function Wizard1Test ()
	local OldManTest = workspace.OldMan1
	local flame1 = OldManTest.Flame1
	local flame2 = OldManTest.Flame2
	
	flame1.RootAttachment.PE1:Emit(10)
	flame2.RootAttachment.PE1:Emit(10)
	OldManTest.OldMan.HumanoidRootPart.RootAttachment.PE1:Emit(15)
	
	wait(0.3)
	
	for i, v in pairs(flame1:GetChildren()) do
		if v:IsA('ParticleEmitter') then
			v.Enabled = true
		end
	end

	for i, v in pairs(flame2:GetChildren()) do
		if v:IsA('ParticleEmitter') then
			v.Enabled = true
		end
	end
	
	coroutine.resume(coroutine.create(function()
		for i, v in pairs(OldManTest.OldMan:GetChildren()) do
			local PrevV = 'HumanoidRootPart'
			if (v:IsA("BasePart") or v:IsA("Decal")) and  v.Name ~= "HumanoidRootPart"  and v.Name ~= PrevV  then
				local partween = ts:Create(v, TweenInfo.new(0.5), {Transparency = 0})
				partween:Play()
			end
			for i, o in pairs(v:GetChildren()) do
				if o:IsA('Decal') then
					local decaltween = ts:Create(o, TweenInfo.new(1), {Transparency = 0})
					decaltween:Play()
				end
			end
		end
	end))
	
	--[[
	
			for i, o in pairs(v:GetChildren()) do
			if o:IsA('Decal') then
				local decaltween = ts:Create(v, TweenInfo.new(1), {Transparency = 0})
				decaltween:Play()
			end
		end
	
	]]

	return
end

-- Sword Area 1 --

hum.Touched:Connect(function(obj)
	local TEnable = workspace:WaitForChild('Files').UndergroundAreaPoints.SwordArea1.TPEnabled
	local platedown = workspace:WaitForChild('Files').UndergroundAreaPoints.SwordArea1.PlateDown
	
	if (obj:IsA('Part') and obj.Name == swordareas.SwordArea1) then
		obj.Plate.CanCollide = false
		plrgui.UIHud.HudInput.Disabled = true
		if TEnable.Value ~= false then
			TEnable.Value = false
			hrp.CFrame = CFrame.new(hrp.Position)
			hrp.Anchored = true
			musichandle:StopMusic()
			local downward = ts:Create(hrp, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {CFrame = hrp.CFrame * CFrame.new(0,-9,0)})
			downward:Play()
			plr.PlayerScripts.Player.Sounds.walkway:Play()
			task.wait(0.8)
			game.Lighting.BlackoutCorrection.Enabled = true
			task.wait(0.8)
			hrp.Anchored = false
			task.wait()
			controls:Disable()
			game.Lighting.BlackoutCorrection.Enabled = false
			game.Lighting.Atmosphere.Density = 0.525
			hrp.CFrame = workspace:WaitForChild('Files').Points.FirstCavePoint.CFrame * CFrame.new(0,3,0)
			cammain.Coordinates.CoordinatePosition.Value = CFrame.new(cammain.Coordinates.CoordinatePosition.Value.X, cammain.Coordinates.CoordinatePosition.Value.Y, 40)
			wait()
			cam:loadcam()
			hud.Line.Text = ''
			hud.Line.Visible = true
			Wizard1Test()
			
			-- [[]] TESTING DIALOGUE AND WEAPON POSSESSION -- [[]]
			
			typewriter:Typewrite(hud.Line, 'ITS DANGEROUS TO GO ALONE! TAKE THIS.')
			task.wait(1)
			controls:Enable()
			plrgui.UIHud.HudInput.Enabled = true

		end
	end
	
	if (obj:IsA('Part') and obj.Name == swordareas.SwordArea1Exit) then
		if TEnable.Value ~= true then
			hrp.CFrame = CFrame.new(hrp.CFrame.Position) * CFrame.Angles(0, -3.15, 0)

			coroutine.resume(coroutine.create(function()
				hrp.Anchored = true
				controls:Disable()
				hrp.CFrame = platedown.CFrame
				local upward = ts:Create(hrp, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = hrp.CFrame * CFrame.new(0,8,0)})
				local forward = ts:Create(hrp, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = hrp.CFrame * CFrame.new(0,0,-4)})
				hud.Line.Text = ''
				hud.Line.Visible = false
				game.Lighting.Atmosphere.Density = 0
				plrgui.UIHud.HudInput.Enabled = false
				cam:manualoadcam(0.6, 3, -9.6)
				cammain.Coordinates.CoordinatePosition.Value = CFrame.new(cammain.Coordinates.CoordinatePosition.Value.X, cammain.Coordinates.CoordinatePosition.Value.Y, 48)
				task.wait(0.8)
				plr.PlayerScripts.Player.Sounds.walkway:Play()
				upward:Play()
				upward.Completed:Wait()
				forward:Play()
			end))
		end
	end
end)

--[[

TEnable.Value = true
hrp.Anchored = false
controls:Enable()

			hrp.Anchored = true
			controls:Disable()
			game.Lighting.BlackoutCorrection.Enabled = true
			hrp.CFrame = CFrame.new(hrp.CFrame.Position) * CFrame.Angles(0, -3.15, 0)
			hrp.CFrame = platedown.CFrame
			hud.Line.Text = ''
			hud.Line.Visible = false
			game.Lighting.Atmosphere.Density = 0
			plrgui.UIHud.HudInput.Enabled = false
			cam:manualoadcam(0.6, 3, -9.6)
			cammain.Coordinates.CoordinatePosition.Value = CFrame.new(cammain.Coordinates.CoordinatePosition.Value.X, cammain.Coordinates.CoordinatePosition.Value.Y, 48)
			task.wait(0.8)
			game.Lighting.BlackoutCorrection.Enabled = false
			plr.PlayerScripts.Player.Sounds.walkway:Play()
			local upward = ts:Create(hrp, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = hrp.CFrame * CFrame.new(0,8,0)})
			local forward = ts:Create(hrp, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = hrp.CFrame * CFrame.new(0,0,-4)})
			upward:Play()
			upward.Completed:Wait()
			forward:Play()
			forward.Completed:Wait()

]]

please help? thank you. it might be something small im not noticing. i dont know.

1 Like

I don’t know if this will hep you but, I starting using PivotTo()

player.Character:PivotTo(CFrame.new(0, 10, 0))

nope.

the player is still stuck in place

would you like a place file to examine the issue more thorougly? (if you have the time of course)

These questions just keep getting harder … :rofl: I guess that’s a good thing.

Try to change this…

hrp.CFrame = platedown.CFrame
local upward = ts:Create(hrp, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = hrp.CFrame * CFrame.new(0,8,0)})
local forward = ts:Create(hrp, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = hrp.CFrame * CFrame.new(0,0,-4)})

To this…

local start = platedown.CFrame
hrp.CFrame = start
local upward = ts:Create(hrp, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = start * CFrame.new(0,8,0)})
local forward = ts:Create(hrp, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = start * CFrame.new(0,8,-4)})

This part is likely the issue, inside the SwordArea1Exit check:

hrp.CFrame = CFrame.new(hrp.CFrame.Position) * CFrame.Angles(0, -3.15, 0)

This may help…

Summary
if obj:IsA('Part') and obj.Name == swordareas.SwordArea1Exit then
	if TEnable.Value ~= true then
		controls:Disable()
		hud.Line.Text = ''
		hud.Line.Visible = false
		game.Lighting.Atmosphere.Density = 0
		plrgui.UIHud.HudInput.Enabled = false
		local start = platedown.CFrame
		hrp.Anchored = true
		hrp.CFrame = start
		cam:manualoadcam(0.6, 3, -9.6)
		cammain.Coordinates.CoordinatePosition.Value = CFrame.new(cammain.Coordinates.CoordinatePosition.Value.X, cammain.Coordinates.CoordinatePosition.Value.Y, 48)
		task.wait(0.8)
		plr.PlayerScripts.Player.Sounds.walkway:Play()
		local up = ts:Create(hrp, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = start * CFrame.new(0,8,0)})
		up:Play()
		up.Completed:Wait()
		local fwd = ts:Create(hrp, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = start * CFrame.new(0,8,-4)})
		fwd:Play()
	end
end

Make sure this name is right: SwordArea1Exit

1 Like

okay so, i had to fix a bit of this script up, and it works, but it only works once :sob:

im trying to find some sort of solution mannn

maybe its something in the game?

I think you’re right… And I think all these scripts work.
I have been on a roll of being wrong this week however.
It’s hard to answer these questions without being able to work with them myself.
Got to just hope it is a pure script error and that isn’t always the case.

You said you had this working just not to the outside. Is it showing any errors?

no errors are being shown… im trying so many things right now lol

I’m just going to take a shot in the dark here and assume it’s because TEnabled never has its value set to true.

So you do ~= false, you then set it to false, you check later for ~= true but then you never set it to true.

Also there is no reason to use coroutine.resume(coroutine.create()), just use task.spawn(function … end)

1 Like

Would you be interesting in learning how to use CFrames?

Solutions from the forum will only get you so far, especially if your questions start to involve big chunks of code (this thread doesn’t actually not too bad in that department, I think). Personally, CFrames are a joy for me, they simplify complex positioning and movement, but have a steep learning curve (especially when you get into CFrame:Inverse()/:ToObjectSpace(), but for your code you don’t need those)

How much do you currently understand about CFrames?

1 Like

hey guys

2 hours from the latest response, i got good news

I got the CFrame to work, with all of your guys’ ideas! thank you so much for the help, all this help was really needed.

i understand CFrame. CFrame just pisses me off sometimes, like whenever im doing something right, i guess whatever im doing is wrong. i dont know maybe its just roblox’s coding language or it could actually be me

not gonna lie, you were definitely right about the task.spawn(function(), i forgot this was a thing lol. this helped out a lot too