Hello, I’ve been trying to create a first person game.
While trying it i wondered how i could see my own body while in first person!
I tried a script but sadly it miss the right arm and the left foot.
Any solution?
local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")
char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
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(0, 0, -(char.Head.Position - pos).magnitude)
else
char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
end
end)
The left foot and right arm probably did not load in, yet. Maybe this will help:
local function adjustLocalTransparency(object)
if not object:IsA("BasePart") or object.Name == "Head" then
return
end
local function setToTransparency()
object.LocalTransparencyModifier = object.Transparency
end
object:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(setToTransparency)
setToTransparency()
end
for _, child in char:GetChildren() do
adjustLocalTransparency(child)
end
char.ChildAdded:Connect(adjustLocalTransparency)