there’s something wrong with my game, which i cant identify the problem
sometimes when ever i want to test the game this happens
and i think it has to do with this script or the other
local players = game:GetService("Players")
local plr = players.LocalPlayer
local runservice = game:GetService("RunService")
local camera = workspace.CurrentCamera
-- Set the camera type to Scriptable once
camera.CameraType = Enum.CameraType.Scriptable
runservice:BindToRenderStep("Camera", 100000, function()
local char = plr.Character
if char then
local tab = {"Head", "HumanoidRootPart"}
for i, limb in pairs(char:GetChildren()) do
if limb and limb:IsA("BasePart") then
if not table.find(tab, limb.Name) then
limb.Transparency = 0
limb.LocalTransparencyModifier = 0
end
end
end
end
end)
runservice.RenderStepped:Connect(function(step)
local char = plr.Character
if char then
local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
local ignoreList = char:GetChildren()
local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
end
end)
or this one
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local event = ReplicatedStorage:WaitForChild("MouseFollowFunctionEvent")
local cam = workspace.CurrentCamera
local function rotateShoulder(shoulder, lookVector)
local shoulderC0 = shoulder.C0
local shoulderpos = shoulderC0.Position
local angleX = lookVector.X
local angleY = lookVector.Y
if angleX <= math.rad(-90) then
angleX = math.rad(-90)
end
shoulder.C0 = CFrame.new(shoulderpos) * CFrame.Angles(angleY, 0, 0)
end
event.OnServerEvent:Connect(function(player, lookVector)
local char = player.Character
if not char then return end
local RUA = char:FindFirstChild("RightUpperArm")
local shoulder = RUA["RightShoulder"]
if RUA then
local tool = char:FindFirstChildWhichIsA("Tool")
if tool then
rotateShoulder(shoulder, lookVector)
else
rotateShoulder(shoulder, Vector3.new(0, 0, 0)) -- Reset rotation if no tool
end
end
end)
local event = game.ReplicatedStorage.MouseFollowFunctionEvent
local player = game.Players
local runservice = game:GetService("RunService")
local cam = workspace.CurrentCamera
local function checkmouseforany()
local angle = cam.CFrame.LookVector
event:FireServer(angle)
end
runservice.RenderStepped:Connect(checkmouseforany)