The title says most of it, Im able to get the function I have under the loop working however the PivotTo is completely unresponsive after death, I have them all under a CharAdded Remote Event and have been stuck here for awhile. Any help appreciated!
function renderloop() --code here irrelevant, works just fine after death
end
CharAdded.OnClientEvent:Connect(function() --remote event created
riggy = rig:Clone() print("rig cloned")
riggy.Parent = CurrentCamera
riggy.PrimaryPart = riggy.HumanoidRootPart
local CamRig = CurrentCamera:WaitForChild("rig")
local righum = rig:WaitForChild("Humanoid")
local charhum = Character:WaitForChild("Humanoid")
if loop then
loop:Disconnect() --if the renderstepped is alr going just disconnect
end
loop = RunService.RenderStepped:Connect(function()
local currentTime = tick()
if not righum and charhum then
return
end
if charhum.MoveDirection.Magnitude > 0 then -- we are walking --this is a camera bob, this doesnt end up working as well since its inside pivotto
isWalking = true
local bobbleX = math.cos(currentTime * 10) * .2
local bobbleY = math.abs(math.sin(currentTime * 10)) * .2
local bobble = Vector3.new(bobbleX, bobbleY, 0)
charhum.CameraOffset = charhum.CameraOffset:Lerp(bobble, .25)
else -- we are not walking
isWalking = false
charhum.CameraOffset = charhum.CameraOffset * .75
end
if isWalking then
x1 = x1 + 0.1
x2 = x2 + 0.1
x3 = x3 + 0.1
WalkingOffset = CFrame.new(
math.sin(x2 * (WalkSpeed/OGWalkSpeed))/-15 ,
math.sin(x1 * (WalkSpeed/OGWalkSpeed))/-15 ,
math.sin(x3 * (WalkSpeed/OGWalkSpeed))/15)
* CFrame.Angles(0,0,0)
else
WalkingOffset = WalkingOffset:Lerp(CFrame.new(), 0.2)
end
if righum then
CamRig:PivotTo(CurrentCamera.CFrame * module.CameraOffset * WalkingOffset)--main issue
end
renderloop()
end)
end)