Hello! So I was recently just working on my game, and for whatever reason, a weird camera glitch (that wasn’t there before) just suddenly appeared. I tried to fix it for the past 2 hours but no luck. Here’s what happens:
I’ve been trying for a bit and I narrowed some of it down:
The part (from what I can tell) gets teleported to a really far away place and destroyed. Idk how this even happens, as there’s no deletion code. This isn’t just for this, either, it’s for like half of the cutscenes (one I made 6 months ago without issue). I’m really confused on what’s happening.
Part is anchored, can collide off, never goes unanchored, just teleports or smth
Camera script:
task.wait()
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local screenshake = false
local screenshakepower = 0
local campart = game.Workspace:WaitForChild("CamPart")
local maxTilt = 5
local ts = game:GetService("TweenService")
local angle = "front"
local previousposition = Vector3.new(0,0,0)
local cando = true
local ismonster1 = false
local anglevalues = {
["right"] = Vector3.new(0,1.5,10),
["left"] = Vector3.new(0,1.5,-10),
["front"] = Vector3.new(-10,1.5,0),
["top"] = Vector3.new(-2,15,0),
["back"] = Vector3.new(10,1.5,0),
["angledfront"] = Vector3.new(-10,7,0),
["birds"] = Vector3.new(-2,25,0)
}
game:GetService("RunService").RenderStepped:Connect(function(deltatime)
local offset = Vector3.new(0,0,0)
local humroot = char:FindFirstChild("HumanoidRootPart")
if cando == true then
local asd = 0
camera.FieldOfView = 72.5
offset = (anglevalues[angle])
local crouchscript = game.Players.LocalPlayer.Character:FindFirstChild("CrouchScript")
if crouchscript ~= nil then
if crouchscript.Crouch.Value == true then
offset = offset - Vector3.new(0,2,0)
end
end
end
local previous100fpsvalues = {}
local fps = 1 / game:GetService("RunService").RenderStepped:wait()
table.insert(previous100fpsvalues,fps)
if #previous100fpsvalues > 100 then
table.remove(previous100fpsvalues,previous100fpsvalues[10])
end
local averagefps = 0
for i,v in ipairs(previous100fpsvalues) do
averagefps = averagefps + v
end
averagefps = averagefps / #previous100fpsvalues
local valuee = 0.08 * (deltatime * (60 + averagefps))
if screenshake == true then
print("changed")
offset = offset + Vector3.new(math.random(screenshakepower * -1, screenshakepower),math.random(screenshakepower * -1, screenshakepower),math.random(screenshakepower * -1, screenshakepower))
end
if cando == true then
if humroot ~= nil then
if ismonster1 == false then
local twen = ts:Create(campart, TweenInfo.new(valuee,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut), {CFrame = CFrame.new((humroot.Position + offset), humroot.Position)})
camera.FieldOfView = 70
twen:Play()
else
local twen = ts:Create(campart, TweenInfo.new(valuee,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut), {CFrame = CFrame.new((humroot.Position + (offset + Vector3.new(0,1.5,0))), game.Workspace.CameraLookAt.Position)})
camera.FieldOfView = 105
twen:Play()
end
end
else
if screenshake == true then
local twen = ts:Create(campart, TweenInfo.new(valuee,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut), {Position = previousposition + offset})
twen:Play()
end
end
camera.CFrame = campart.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 1.5)/mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 1.5)/mouse.ViewSizeX)) * -maxTilt),
0
)
end)
Cutscene code (Inside camera script; right under the main camera code)
game.ReplicatedStorage.DiscoverMonsterCutscene.OnClientEvent:Connect(function(typee)
local epic = campart.CFrame
cando = false
local twen = ts:Create(campart, TweenInfo.new(1,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out), {CFrame = game.Workspace.SecondMonsterMap.HandPuzzle.Camerae.CFrame})
twen:Play()
task.wait(3)
local twen = ts:Create(campart, TweenInfo.new(1,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out), {CFrame = epic})
twen:Play()
cando = true
end)
Idk what happened, please help I do not wanna give up on this game