Egomooses gravity controller new camera does not work with teleports

idk how to make the teleports properly teleport

LINK TO GAME (open source)

https://www.roblox.com/games/4631060850/Wall-stick-controller-new-camera#!/game-instances

CODE FOR TELEPORTER

local buttons = {}
local doors = {}
local teleports = {}
local running = false
local opening = false

function CheckChildren(obj)
for i, v in pairs(obj:GetChildren()) do
if v.Name == “Doors” then
table.insert(doors, v)
elseif v.Name == “Button” then
table.insert(buttons, v)
elseif v.Name == “Teleport” then
table.insert(teleports, v)
end
CheckChildren(v)
end
end

CheckChildren(script.Parent)

function openDoors()
if not opening then
opening = true
for i, v in pairs(buttons) do
v.DoorSound:Play()
end
for i = 1, 37 do
for i, v in pairs(doors) do
v.LeftDoor:SetPrimaryPartCFrame(v.LeftDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(2), 0))
v.RightDoor:SetPrimaryPartCFrame(v.RightDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-2), 0))
end
wait()
end
running = false
end
opening = false
end

function closeDoors()
for i = 1, 37 do
for i, v in pairs(buttons) do
v.DoorSound:Play()
end
for i, v in pairs(doors) do
v.LeftDoor:SetPrimaryPartCFrame(v.LeftDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-2), 0))
v.RightDoor:SetPrimaryPartCFrame(v.RightDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(2), 0))
end
wait()
end
end

function moveChars(teleport)
local p = teleport.Parent.Floor.Position
local region = Region3.new(p - Vector3.new(2.2, 0, 2.2), p + Vector3.new(2.2, 7, 2.2))
local parts = workspace:FindPartsInRegion3(region, nil, math.huge)
local chars = {}

for _, v in pairs(parts) do
	if v.Parent:FindFirstChild("Humanoid") then
		local match = false
		for i, c in pairs(chars) do
			if chars[i] == v.Parent then
				match = true
			end
		end
		if not match then
			table.insert(chars, v.Parent)
		end
	end
end	

for i = 0, 1, 0.05 do
	for _, v in pairs(chars) do
		for x, c in pairs(v:GetChildren()) do
			if c:IsA("BasePart") and c.Name ~= "HumanoidRootPart" then
				c.Transparency = i
			elseif c:FindFirstChild("Handle") then
				c.Handle.Transparency = i
			end
		end
	end
	wait()
end

local newTeleport
for i, v in pairs(teleports) do
	if v ~= teleport then
		newTeleport = v
	end
end
local posA = teleport.Parent.Floor.Position
local posB = newTeleport.Parent.Floor.Position
local offset = posB - posA
print(offset)

for _, v in pairs(chars) do
	v:TranslateBy(offset)
end

for i = 1, 0, -0.05 do
	for _, v in pairs(chars) do
		for x, c in pairs(v:GetChildren()) do
			if c:IsA("BasePart") and c.Name ~= "HumanoidRootPart" then
				c.Transparency = i
			elseif c:FindFirstChild("Handle") then
				c.Handle.Transparency = i
			end
		end
	end
	wait()
end

end

function runEffect(teleport)
local emitters = {}
local t = 100 – delay timer
local maxP = 50 – max particles
local n = 240 – number of iterations for startup and cooldown
local r = 100 – run time at full speed

for i, v in pairs(teleport:GetChildren()) do
	if v:FindFirstChild("ParticleEmitter") then
		table.insert(emitters, v)
	end
end

for i = 1, n do
	teleport:SetPrimaryPartCFrame(teleport.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(i/10), 0))
	for e = 1, 4 do
		emitters[e].Transparency = math.max((t-i)/t, 0)
		emitters[e].ParticleEmitter.Rate = math.min(i - t, maxP)
	end
	wait()
end
for i = 1, 100 do
	teleport:SetPrimaryPartCFrame(teleport.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(20), 0))
	wait()
	if i == 40 then
		spawn(function()
			moveChars(teleport)
		end)
	end
end
for i = n, 0, -1 do
	teleport:SetPrimaryPartCFrame(teleport.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(i/10), 0))
	for e = 1, 4 do
		emitters[e].Transparency = math.max(t/i, 0)
		emitters[e].ParticleEmitter.Rate = math.min(i -1 , maxP)
	end
	wait()
end
wait(1)
openDoors()

end

for i, v in pairs(buttons) do – when a player clicks on the teleport button
v.ClickDetector.MouseClick:connect(function()
v.ButtonSound:Play()
v.CFrame = v.CFrame * CFrame.new(0.05, 0, 0)
wait()
v.CFrame = v.CFrame * CFrame.new(-0.05, 0, 0)
if not running then
running = true
wait(1)
closeDoors()
wait(1)
for i, v in pairs(teleports) do
spawn(function()
runEffect(v)
end)
end
end
end)
end

for i, v in pairs(doors) do – set up initial door positions
v.LeftDoor:SetPrimaryPartCFrame(v.LeftDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(74), 0))
v.RightDoor:SetPrimaryPartCFrame(v.RightDoor.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-74), 0))
end

1 Like