I am making a Battle Royale game and I do not know how to script the camera like what it does in Island Royale.
place in StarterPack; i will explain everything below
local rs = game:GetService("RunService") local uip = game:GetService("UserInputService") local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local cam = workspace.CurrentCamera local angX = 0 local angY = 0 local camPos = Vector3.new(3.5, 0, 7.5) wait(.1) cam.CameraType = Enum.CameraType.Scriptable uip.MouseBehavior = Enum.MouseBehavior.LockCenter uip.InputChanged:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then angX = angX - input.Delta.X * .4 angY = math.clamp(angY - input.Delta.Y * .4, -80, 80) end end) rs.RenderStepped:Connect(function() local char = plr.Character local root = char:FindFirstChild("HumanoidRootPart") local waist = char:FindFirstChild("Waist", true) local neck = char:FindFirstChild("Neck", true) if char and root then local dir = (root.CFrame:Inverse() * cam.CFrame).LookVector root.CFrame = root.CFrame * CFrame.Angles(0, -math.asin(dir.X), 0) waist.C1 = CFrame.new(waist.C1.p) * CFrame.Angles(-math.asin(dir.Y) / 2, math.asin(dir.X) / 2, 0) neck.C1 = CFrame.new(neck.C1.p) * CFrame.Angles(-math.asin(dir.Y) / 2, math.asin(dir.X) / 2, 0) local startCFrame = CFrame.new((root.Position + Vector3.new(0, 2, 0))) * CFrame.Angles(0, math.rad(angX), 0) * CFrame.Angles(math.rad(angY), 0, 0) local camCFrame = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(camPos.X, camPos.Y, camPos.Z)) local camFocus = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(camPos.X, camPos.Y, -99999)) cam.CFrame = CFrame.new(camCFrame.p, camFocus.p) end end)
so what dis does in essence is lock the mouse at the center, constantly offset the camera's position while making the player turn on the X axis to face the mouse and I added some dynamics to the character's stale body.
Closed as Not Constructive by Gey4Jesus69 and User#24403
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?