Hello! My firstPerson works in studio but not in game itself. In studio it does what it’s supoosed to, but in game it makes me have to jump to do things like walk up a staircase, or walk on the ground because of the arms going to far in the ground.
script:
local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService(“RunService”)
for i, v in pairs(char:GetChildren()) do
if v:IsA(“BasePart”) and v.Name ~= “Head” then
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
v.LocalTransparencyModifier = v.Transparency
end)
v.LocalTransparencyModifier = v.Transparency
end
end
RunService.RenderStepped:Connect(function(step)
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)
if hit then
char.Humanoid.CameraOffset = Vector3.new(-1, 0, -(char.Head.Position - pos).magnitude)
else
char.Humanoid.CameraOffset = Vector3.new(0, 0, -2)
end
maybe you’re trying to access the character before it exists. it loads/spawns faster in studio
try doing local char = player.Character or player.CharacterAdded:Wait()
also, test it using a local server from the test tab of studio rather than a normal test
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local char = player.Character
local RunService = game:GetService(“RunService”)
for i, v in pairs(char:GetChildren()) do
local char = player.Character or player.CharacterAdded:Wait()
if v:IsA(“BasePart”) and v.Name ~= “Head” then
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
v.LocalTransparencyModifier = v.Transparency
end)
v.LocalTransparencyModifier = v.Transparency
end
end
RunService.Heartbeat:Connect(function(step)
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)
if hit then
char.Humanoid.CameraOffset = Vector3.new(5, 5, -(char.Head.Position - pos).magnitude)
else
char.Humanoid.CameraOffset = Vector3.new(0, 0, -2)
end
end) Maybe I did something wrong when I changed the script.