I’m trying to make a camera like Hellmet but I don’t understand how to
I can’t seem to make the character look around with the mouse
I tried making the camera scriptable and making my own camera script although it still doesn’t move
The mouse in helmet is locked In the center of the screen using only the mouse delta helmet points a viewmodel to the direction of the last delta while clamping the rotation to make sure the viewmodel dosnt go backwards and making the arms transparent so you wont notice the difference and with providing a simple offset based off the head cframe like this (Head.CFrame * CFrame.new(Vector3.new(1.2, 0.5, 0.6)))
I assume your trying to do it like this
if so here is the code.
local camera = game.Workspace.Camera
local Players = game:GetService("Players")
local Rs = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local CS = game:GetService("ContextActionService")
local Player = Players.LocalPlayer
local Charecter:Model = Player.Character
local Head:Part = Charecter:WaitForChild("Head")
local Torso:Part = Charecter:WaitForChild("Torso")
local Neck:Motor6D = Torso:WaitForChild("Neck")
local Humanoid:Humanoid = Charecter:WaitForChild("Humanoid")
local HumanoidRootPart:Part = Charecter:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()
Humanoid.AutoRotate = false
local Dead = false
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 120
local currentxoffset = 1.2
local HelmetPositonLoop
local InputConnection
local MouseConneciton
HelmetPositonLoop = Rs.RenderStepped:Connect(function()
camera.CFrame = (Head.CFrame * CFrame.new(Vector3.new(currentxoffset, 0.5, 0.6)))
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
end)
local CurrentXDelta = 0
local CurrentYDelta = 0
local NeckCahce = Neck.C0
function MouseMoved(actionName:string, inputState, inputObject:InputObject)
local Neckc0Store:CFrame = Neck.C0
local CompressedDelta:Vector2 = Vector2.new(inputObject.Delta.X,inputObject.Delta.Y)
CurrentXDelta = CompressedDelta.X
CurrentYDelta = CompressedDelta.Y
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:Lerp(HumanoidRootPart.CFrame * CFrame.Angles(0, -math.rad(CurrentXDelta/2), 0),1)
local RotationX, RotationY, RotationZ = Neckc0Store:ToEulerAnglesXYZ()
local NewRotX = math.deg(RotationX+ -CurrentYDelta/200)
NewRotX = math.clamp(NewRotX,-160,-10)
Neck.C0 = Neck.C0:Lerp(CFrame.new(Neckc0Store.Position)*CFrame.Angles(math.rad(NewRotX),RotationY,RotationZ),1)
end
MouseConneciton = CS:BindAction("MouseMoved",MouseMoved,false,Enum.UserInputType.MouseMovement)
InputConnection = UIS.InputBegan:Connect(function(input:InputObject,GPE:boolean)
if GPE then return end
local Keycode = input.KeyCode
if Keycode == Enum.KeyCode.Q then
currentxoffset = -currentxoffset
elseif Keycode == Enum.KeyCode.E then
currentxoffset = math.abs(currentxoffset)
end
--print(currentxoffset)
end)
Humanoid.Died:Connect(function()
if Dead == true then return end
Dead = true
InputConnection:Disconnect()
CS:UnbindAction("MouseMoved")
task.wait(Players.RespawnTime)
HelmetPositonLoop:Disconnect()
end)
I hope this is enough to kick start you
also if this is a solution feel free to mark it
also if anyone needs explinations for the code feel free to shoot a meesage.
How would I make it so all of the accessories of my character don’t glitch and stuff since the camera is in them?
Can i get a screenshot of that issue?
Off bat i can tell you straight forward you could remove accesories that cause those issues by checking what the name of attachment it has and then looping through the charecter and removing any acessory with that attachtment name.
But if you want the charecter to be some sort of custom charecter you can set a startercharecter
rewriting the script rq to make it easier to fix this
Mess with the variable called offset this will fix the issue
This is a script with some changes as i found a bug before with the camera changing using the q and e keys and that is fixed here in this new one
local camera = game.Workspace.Camera
local Players = game:GetService("Players")
local Rs = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local CS = game:GetService("ContextActionService")
local Player = Players.LocalPlayer
local Charecter:Model = Player.Character
local Head:Part = Charecter:WaitForChild("Head")
local Torso:Part = Charecter:WaitForChild("Torso")
local Neck:Motor6D = Torso:WaitForChild("Neck")
local Humanoid:Humanoid = Charecter:WaitForChild("Humanoid")
local HumanoidRootPart:Part = Charecter:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()
Humanoid.AutoRotate = false
local Dead = false
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 120
local Offfset = 1.2 --Mess With this value the more you add to this number it becomes oriented to the right if negative oriented to the left
local currentxoffset = Offfset
local HelmetPositonLoop
local InputConnection
local MouseConneciton
HelmetPositonLoop = Rs.RenderStepped:Connect(function()
camera.CFrame = (Head.CFrame * CFrame.new(Vector3.new(currentxoffset, 0.5, 0.6)))
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
end)
local CurrentXDelta = 0
local CurrentYDelta = 0
local NeckCahce = Neck.C0
function MouseMoved(actionName:string, inputState, inputObject:InputObject)
local Neckc0Store:CFrame = Neck.C0
local CompressedDelta:Vector2 = Vector2.new(inputObject.Delta.X,inputObject.Delta.Y)
CurrentXDelta = CompressedDelta.X
CurrentYDelta = CompressedDelta.Y
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:Lerp(HumanoidRootPart.CFrame * CFrame.Angles(0, -math.rad(CurrentXDelta/2), 0),1)
local RotationX, RotationY, RotationZ = Neckc0Store:ToEulerAnglesXYZ()
local NewRotX = math.deg(RotationX+ -CurrentYDelta/200)
NewRotX = math.clamp(NewRotX,-160,-10)
Neck.C0 = Neck.C0:Lerp(CFrame.new(Neckc0Store.Position)*CFrame.Angles(math.rad(NewRotX),RotationY,RotationZ),1)
end
MouseConneciton = CS:BindAction("MouseMoved",MouseMoved,false,Enum.UserInputType.MouseMovement)
InputConnection = UIS.InputBegan:Connect(function(input:InputObject,GPE:boolean)
if GPE then return end
local Keycode = input.KeyCode
if Keycode == Enum.KeyCode.Q and currentxoffset ~= -Offfset then
currentxoffset = -Offfset
end
if Keycode == Enum.KeyCode.E and currentxoffset ~= math.abs(Offfset) then
currentxoffset = math.abs(Offfset)
end
--print(currentxoffset)
end)
Humanoid.Died:Connect(function()
if Dead == true then return end
Dead = true
InputConnection:Disconnect()
CS:UnbindAction("MouseMoved")
task.wait(Players.RespawnTime)
HelmetPositonLoop:Disconnect()
end)```
tell me if it wokred please (waeqeqweqewweqe)
“Workspace.JellyM015.Script:10: attempt to index nil with ‘Character’”
Spoiler:It does not work.
Thats weird there might be some latency in the project
try this it works perfect for me
repeat task.wait() until game:IsLoaded()
local camera = game.Workspace.Camera
local Players = game:GetService("Players")
local Rs = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local CS = game:GetService("ContextActionService")
local Player = Players.LocalPlayer
local Charecter:Model = Player.Character
local Head:Part = Charecter:WaitForChild("Head")
local Torso:Part = Charecter:WaitForChild("Torso")
local Neck:Motor6D = Torso:WaitForChild("Neck")
local Humanoid:Humanoid = Charecter:WaitForChild("Humanoid")
local HumanoidRootPart:Part = Charecter:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()
Humanoid.AutoRotate = false
local Dead = false
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 120
local Offfset = 1.2 --Mess With this value the more you add to this number it becomes oriented to the right if negative oriented to the left
local currentxoffset = Offfset
local HelmetPositonLoop
local InputConnection
local MouseConneciton
HelmetPositonLoop = Rs.RenderStepped:Connect(function()
camera.CFrame = (Head.CFrame * CFrame.new(Vector3.new(currentxoffset, 0.5, 0.6)))
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
end)
local CurrentXDelta = 0
local CurrentYDelta = 0
local NeckCahce = Neck.C0
function MouseMoved(actionName:string, inputState, inputObject:InputObject)
local Neckc0Store:CFrame = Neck.C0
local CompressedDelta:Vector2 = Vector2.new(inputObject.Delta.X,inputObject.Delta.Y)
CurrentXDelta = CompressedDelta.X
CurrentYDelta = CompressedDelta.Y
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:Lerp(HumanoidRootPart.CFrame * CFrame.Angles(0, -math.rad(CurrentXDelta/2), 0),1)
local RotationX, RotationY, RotationZ = Neckc0Store:ToEulerAnglesXYZ()
local NewRotX = math.deg(RotationX+ -CurrentYDelta/200)
NewRotX = math.clamp(NewRotX,-160,-10)
Neck.C0 = Neck.C0:Lerp(CFrame.new(Neckc0Store.Position)*CFrame.Angles(math.rad(NewRotX),RotationY,RotationZ),1)
end
MouseConneciton = CS:BindAction("MouseMoved",MouseMoved,false,Enum.UserInputType.MouseMovement)
InputConnection = UIS.InputBegan:Connect(function(input:InputObject,GPE:boolean)
if GPE then return end
local Keycode = input.KeyCode
if Keycode == Enum.KeyCode.Q and currentxoffset ~= -Offfset then
currentxoffset = -Offfset
end
if Keycode == Enum.KeyCode.E and currentxoffset ~= math.abs(Offfset) then
currentxoffset = math.abs(Offfset)
end
--print(currentxoffset)
end)
Humanoid.Died:Connect(function()
if Dead == true then return end
Dead = true
InputConnection:Disconnect()
CS:UnbindAction("MouseMoved")
task.wait(Players.RespawnTime)
HelmetPositonLoop:Disconnect()
end)
Still, doesn’t work.
Does it have to do with it being meant for R15, or maybe cause I’m using ACS?
WAit r15? Bruhhhhhhhhhhh yes ill send a new script
Here is the r15 script
Please try this and tell me quick
repeat task.wait() until game:IsLoaded()
local camera = game.Workspace.Camera
local Players = game:GetService("Players")
local Rs = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local CS = game:GetService("ContextActionService")
local Player = Players.LocalPlayer
local Charecter:Model = Player.Character
local Head:Part = Charecter:WaitForChild("Head")
local Torso:Part = Charecter:WaitForChild("UpperTorso")
local Neck:Motor6D = Head:WaitForChild("Neck")
local Humanoid:Humanoid = Charecter:WaitForChild("Humanoid")
local HumanoidRootPart:Part = Charecter:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()
Humanoid.AutoRotate = false
local Dead = false
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 120
local Offfset = 1.2 --Mess With this value the more you add to this number it becomes oriented to the right if negative oriented to the left
local currentxoffset = Offfset
local HelmetPositonLoop
local InputConnection
local MouseConneciton
HelmetPositonLoop = Rs.RenderStepped:Connect(function()
camera.CFrame = (Head.CFrame * CFrame.new(Vector3.new(currentxoffset, 0.5, 0.6)))
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
end)
local CurrentXDelta = 0
local CurrentYDelta = 0
local NeckCahce = Neck.C0
function MouseMoved(actionName:string, inputState, inputObject:InputObject)
local Neckc0Store:CFrame = Neck.C0
local CompressedDelta:Vector2 = Vector2.new(inputObject.Delta.X,inputObject.Delta.Y)
CurrentXDelta = CompressedDelta.X
CurrentYDelta = CompressedDelta.Y
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:Lerp(HumanoidRootPart.CFrame * CFrame.Angles(0, -math.rad(CurrentXDelta/2), 0),1)
local RotationX, RotationY, RotationZ = Neckc0Store:ToEulerAnglesXYZ()
local NewRotX = math.deg(RotationX+ -CurrentYDelta/200)
NewRotX = math.clamp(NewRotX,-85,65)
Neck.C0 = Neck.C0:Lerp(CFrame.new(Neckc0Store.Position)*CFrame.Angles(math.rad(NewRotX),RotationY,RotationZ),1)
end
MouseConneciton = CS:BindAction("MouseMoved",MouseMoved,false,Enum.UserInputType.MouseMovement)
InputConnection = UIS.InputBegan:Connect(function(input:InputObject,GPE:boolean)
if GPE then return end
local Keycode = input.KeyCode
if Keycode == Enum.KeyCode.Q and currentxoffset ~= -Offfset then
currentxoffset = -Offfset
end
if Keycode == Enum.KeyCode.E and currentxoffset ~= math.abs(Offfset) then
currentxoffset = math.abs(Offfset)
end
--print(currentxoffset)
end)
Humanoid.Died:Connect(function()
if Dead == true then return end
Dead = true
InputConnection:Disconnect()
CS:UnbindAction("MouseMoved")
task.wait(Players.RespawnTime)
HelmetPositonLoop:Disconnect()
end)
Real qucik if this one dosnt work send me a screenshot of the explorer when the project is ran and when the project is not ran to see if acs has named things to different names