Hey, I am making locker animation but it looks goofy and not as it shoud look. How can I fix this stupid problem?
- The camera should always be in the same position as the player’s head
- Camera should lock and face 180 more degrees from the start position
- When animations are done the camera should have this position:
character:FindFirstChild("Humanoid").CameraOffset = Vector3.new(0,0,-1)
end)
VIDEO:
Here is all codes:
Proximityprompt activation script:
script.Parent.Enabled = true
script.Parent.Triggered:Connect(function(plr)
game.ReplicatedStorage.ButtonEvents.closetE:FireClient(plr, script.Parent.Parent.Parent)
script.Parent.Enabled = false
end)
local script:
local repl = game.ReplicatedStorage
local ts = game:GetService("TweenService")
local closetanim = TweenInfo.new(
.9,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out
)
repl.ButtonEvents.closetE.OnClientEvent:Connect(function(obj)
local plr = game.Players.LocalPlayer
local plrHum = plr.Character.HumanoidRootPart
local playerCamera = workspace.CurrentCamera
repl.ButtonEvents.closetE:FireServer(obj)
playerCamera.CameraType = "Scriptable"
local out = obj.Outside
local inside = obj.Inside
local camin = obj.CamInside
local door = obj.door
playerCamera.CFrame = out.CFrame
plrHum.Anchored = true
local closettween = ts:Create(playerCamera, closetanim, {CFrame = CFrame.new(camin.CFrame.Position.X, playerCamera.CFrame.Position.Y, camin.CFrame.Position.Z)}):Play()
local closettween2 = ts:Create(playerCamera, closetanim, {CFrame = camin.CFrame * CFrame.Angles(0, 180, 0)}):Play()
closettween2.Completed:Wait()
wait(1)
playerCamera.CFrame = camin.CFrame
playerCamera.CameraType = "Fixed"
plr.Character:FindFirstChild("Humanoid").CameraOffset = Vector3.new(0,0,-1)
local targetPosition = plr.Character:WaitForChild("Head").Position
playerCamera.CFrame = CFrame.new(targetPosition, targetPosition + plrHum.CFrame.LookVector)
local character = (game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait())
character:FindFirstChild("Humanoid").CameraOffset = Vector3.new(0,0,-1)
end)