when I walk, the part itself moves, and I can’t stop it because it follows the camera, and it moves because of a local script that I don’t want to turn off, and it makes the camera sway.
--The CameraFps script
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
repeat task.wait() until player.Character
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local baseCFrameValue
local BobSpeed = 0.3
local SwayIntensity = 1
local PI = math.pi
local BASE_FOV = 80
local running, strafing = false, false
local VariableTick = PI / 6
local swayValue = 0
local Z = 0
local BASE_PRIORITY = Enum.RenderPriority.Camera.Value + 0.25
local SHAKE_PRIORITY = Enum.RenderPriority.Camera.Value + 1
local function mix(a, b, t)
return b + (a - b) * t
end
local function aiming()
return humanoid:GetAttribute("GunAiming") == true
end
local function ensureCamera()
if workspace.CurrentCamera ~= camera then
camera = workspace.CurrentCamera
baseCFrameValue = nil
end
if camera then
if not baseCFrameValue or baseCFrameValue.Parent ~= camera then
baseCFrameValue = Instance.new("CFrameValue")
baseCFrameValue.Name = "UnshakenCFrame"
baseCFrameValue.Archivable = false
baseCFrameValue.Value = camera.CFrame
baseCFrameValue.Parent = camera
end
if not aiming() and math.abs(camera.FieldOfView - BASE_FOV) > 0.05 then
camera.FieldOfView = BASE_FOV
end
end
end
local lastBaseCF = CFrame.new()
local strafingSignal = humanoid:FindFirstChild("Strafing")
if strafingSignal then
strafingSignal.Changed:Connect(function(val)
strafing = val
end)
end
humanoid.Running:Connect(function(speed)
running = speed > 0.1
end)
humanoid.Jumping:Connect(function()
running = false
end)
humanoid.Swimming:Connect(function()
running = false
end)
RunService:UnbindFromRenderStep("CameraBaseRecord")
RunService:BindToRenderStep("CameraBaseRecord", BASE_PRIORITY, function()
ensureCamera()
if not camera or not baseCFrameValue then
return
end
lastBaseCF = camera.CFrame
baseCFrameValue.Value = lastBaseCF
end)
RunService:UnbindFromRenderStep("CameraSway")
RunService:BindToRenderStep("CameraSway", SHAKE_PRIORITY, function(dt)
if not camera or not baseCFrameValue then
return
end
local baseCF = lastBaseCF
if aiming() then
camera.CFrame = baseCF
return
end
local dx = UserInputService:GetMouseDelta().X
swayValue += (math.clamp(dx, -6, 6) - swayValue) * (6 * dt)
local swayCF = CFrame.Angles(0, 0, math.rad(swayValue * SwayIntensity))
local speed = humanoid.WalkSpeed
local damping = math.max(speed / 2, 1)
if running and not strafing then
VariableTick += (speed * BobSpeed) / 92
else
local vt = VariableTick
if vt < PI / 2 then
VariableTick = mix(vt, PI / 2, 0.9)
elseif vt < PI then
VariableTick = mix(vt, PI / 2, 0.9)
elseif vt < PI * 1.5 then
VariableTick = mix(vt, PI * 1.5, 0.9)
else
VariableTick = mix(vt, PI * 1.5, 0.9)
end
end
if VariableTick >= PI * 2 then
VariableTick -= PI * 2
end
local tick = VariableTick
local cos, sin = math.cos, math.sin
local bobCF =
CFrame.new(
cos(tick) / damping,
sin(tick * 2) / (damping * 2),
Z
)
* CFrame.Angles(0, 0, sin(tick - PI * 1.5) / (damping * 20))
camera.CFrame = baseCF * swayCF * bobCF
end)
--3D Gui script
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local GlowFolder = Workspace:WaitForChild("GlowUi")
local DEFAULT_DEPTH = 0.5
local DEFAULT_SIZE_X = 1
local DEFAULT_SIZE_Y = 1
local DEFAULT_POS_X = 0.5
local DEFAULT_POS_Y = 0.5
local Z_PAD = 0.5
local PRIORITY = Enum.RenderPriority.Last.Value + 50
local tracked = {}
local lastStableCF = nil
local function preparePart(part: BasePart)
part.Anchored = true
part.CanCollide = false
part.CanTouch = false
part.CanQuery = true
part.Massless = true
part.CastShadow = false
end
local function trackPart(inst: Instance)
if inst:IsA("BasePart") then
preparePart(inst)
tracked[inst] = true
end
end
local function untrackPart(inst: Instance)
if inst:IsA("BasePart") then
tracked[inst] = nil
end
end
local function getCameraFrame(cam: Camera?)
local baseValue = cam and cam:FindFirstChild("UnshakenCFrame")
if baseValue and baseValue:IsA("CFrameValue") then
lastStableCF = baseValue.Value
return lastStableCF
end
if lastStableCF then
return lastStableCF
end
return cam and cam.CFrame
end
for _, inst in ipairs(GlowFolder:GetDescendants()) do
trackPart(inst)
end
GlowFolder.DescendantAdded:Connect(trackPart)
GlowFolder.DescendantRemoving:Connect(untrackPart)
RunService:UnbindFromRenderStep("GlowUiFollow")
RunService:BindToRenderStep("GlowUiFollow", PRIORITY, function()
local cam = Workspace.CurrentCamera
if not cam then return end
local vp = cam.ViewportSize
if vp.Y <= 0 then return end
local camCF = getCameraFrame(cam)
local theta = math.tan(math.rad(cam.FieldOfView) * 0.5)
local aspect = vp.X / vp.Y
for part in pairs(tracked) do
if not part.Parent then
tracked[part] = nil
continue
end
local depth = part:GetAttribute("Depth") or DEFAULT_DEPTH
local sizeX = part:GetAttribute("UiSizeX") or DEFAULT_SIZE_X
local sizeY = part:GetAttribute("UiSizeY") or DEFAULT_SIZE_Y
local posX01 = part:GetAttribute("UiPosX") or DEFAULT_POS_X
local posY01 = part:GetAttribute("UiPosY") or DEFAULT_POS_Y
local fullH = 2 * depth * theta
local fullW = fullH * aspect
local thickness = part:GetAttribute("Thickness") or part.Size.Z
part.Size = Vector3.new(fullW * sizeX, fullH * sizeY, thickness)
local x = (posX01 - 0.5) * fullW
local y = -(posY01 - 0.5) * fullH
part.CFrame = camCF * CFrame.new(x, y, -(depth + Z_PAD))
end
end)
help please