Hi! I am trying to make a custom platformer camera, and I made this. It works, though it kinda lags behind the player. This script spawns a part that follows you player and your camera goes to this part. What I am trying to do is make the part not lag behind the player. This is inside serverscriptservice BTW
--Variables--
local Players = game.Players
-- Join script
Players.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(function(Char)
local HRP = Char.HumanoidRootPart
local CamPart = Instance.new("Part",workspace.CamParts)
CamPart.Anchored = true
CamPart.Name = Plr.Name
CamPart.Transparency = 1
while wait() do
CamPart.Position = Vector3.new(HRP.Position.x,HRP.Position.y, HRP.Position.z+20)
end
end)
end)
Here is the camera script. I know it is probably the waitforchild inside the loop, but i found it is the only wayit works.
--Variables--
local Player = game.Players.LocalPlayer
local Camera = workspace.Camera
local CamParts = workspace.CamParts
--Cam script--
Camera.CameraType = Enum.CameraType.Scriptable
while wait() do
local CamPart = CamParts:FindFirstChild(Player.Name)
if CamPart then
Camera.CFrame = CamPart.CFrame
end
end