So, I was messing around making a teleport script and I settled on something I liked that had this weird effect, but the issue with it is that whenever the whole animation thingymajig is finished the camera orientation isn’t kept. Anyone got a clue on how to fix that?
Teleport LocalScript:
local inputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local repStorage = game:GetService("ReplicatedStorage")
local mouse = game.Players.LocalPlayer:GetMouse()
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humrp = char:WaitForChild("HumanoidRootPart")
local charheight = Vector3.new(0,char:GetExtentsSize().Y + 1, 0)
inputService.InputBegan:Connect(function(inp, gpe)
if gpe == false then
if inputService:IsKeyDown(Enum.KeyCode.T) then
if mouse.Target and char.Humanoid.FloorMaterial ~= Enum.Material.Air then
local teleportPos = mouse.Hit - charheight
local portalTween = tweenService:Create(humrp,
TweenInfo.new(0.4, Enum.EasingStyle.Linear),
{CFrame = teleportPos + charheight*2})
for _, v in pairs(char:GetChildren()) do
if v:isA("Part") then
v.CollisionGroup = "Noclip"
end
end
task.wait(0.35)
humrp.Anchored = true
char:PivotTo(CFrame.new(0,0,0,0,0,0,0) * teleportPos)
print(CFrame.new(0,0,0,0,0,0,0) * teleportPos)
portalTween:Play()
portalTween.Completed:Wait()
for _, v in pairs(char:GetChildren()) do
if v:isA("Part") then
v.CollisionGroup = "Default"
end
end
humrp.Anchored = false
char.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end
end
end)
Video Showcasing Issue:
On a sidenote, anybody got a clue what causes that weird strobe effect? I’m assuming it’s because the inputted teleport position is null (or atleast I’m assuming it is null), but the HMRP never says the CFrame is set to null or NAN.