The title says it all, Achieving the camera view under tables like the screenshot below.
Set the player’s camera to first person.
Here is a link on how to do that: First person script is not working
Well you can set the camera’s offset a little lower if you want.
There’s a property called “CameraOffset” in the player’s character’s humanoid.
You can set the camera offset to 0,-2,0 maybe or a little bit higher if you want. It’s all your choice. (By the way this is scriptable too.)
Nope, the camera offset won’t lower, Here is the code.
local PersonHiding = nil
local h = false
local Can = true
local lockerdoor = script.Parent
local prompt = lockerdoor.ProximityPrompt
local opens = lockerdoor.Sound
local locker = lockerdoor.Parent
local part = locker.PrimaryPart
local function TagSYS(P, Name, Remove)
if Remove == false then
local v = Instance.new("BoolValue")
v.Parent = P
v.Name = Name
else
if P:FindFirstChild(Name) then
P:FindFirstChild(Name):Destroy()
end
end
end
local function Enter(character)
if not character then return end
if not character:FindFirstChild("HumanoidRootPart") then return end
if not character:FindFirstChildOfClass("Humanoid") then return end
if character:FindFirstChild("CantHide") then return end
h = true
Can = false
PersonHiding = character
prompt.Enabled = false
prompt.ActionText = "Exit"
TagSYS(character, "CantHide", false)
opens:Play()
character:FindFirstChildOfClass("Humanoid").WalkSpeed = 0
character:FindFirstChildOfClass("Humanoid").JumpPower = 0
character:FindFirstChild("HumanoidRootPart").Anchored = true
character:FindFirstChild("HumanoidRootPart").CFrame = part.CFrame
local anim = character:FindFirstChildOfClass("Humanoid"):WaitForChild("Animator")
if anim then
local animation = Instance.new("Animation", anim)
animation.AnimationId = "rbxassetid://17371888743"
local animTrack = anim:LoadAnimation(animation)
animTrack:Play()
end
character:FindFirstChildOfClass("Humanoid").CameraOffset = Vector3.new(0, -1.5, 0)
TagSYS(character, "Hidden", false)
TagSYS(character, "InTable", false)
task.wait(0.75)
prompt.Enabled = true
Can = true
end
local function Exit(check)
while not Can do
task.wait(0.175)
end
local savedPersonHiding = PersonHiding
h = false
Can = false
PersonHiding = nil
prompt.Enabled = false
prompt.ActionText = "Enter"
spawn(function()
if not savedPersonHiding then return end
if not savedPersonHiding:FindFirstChild("HumanoidRootPart") then return end
if not savedPersonHiding:FindFirstChildOfClass("Humanoid") then return end
opens:Play()
savedPersonHiding:FindFirstChild("HumanoidRootPart").Anchored = false
savedPersonHiding:FindFirstChild("HumanoidRootPart").CFrame = part.CFrame * CFrame.new(0,0,-5)
savedPersonHiding:FindFirstChildOfClass("Humanoid").WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
savedPersonHiding:FindFirstChildOfClass("Humanoid").JumpPower = game.StarterPlayer.CharacterJumpPower
local anim = savedPersonHiding:FindFirstChildOfClass("Humanoid"):WaitForChild("Animator")
if anim then
local animation = Instance.new("Animation", anim)
animation.AnimationId = "rbxassetid://17371888743"
local animTrack = anim:LoadAnimation(animation)
animTrack:Play()
task.wait(0.001)
animTrack:Stop()
end
savedPersonHiding:FindFirstChildOfClass("Humanoid").CameraOffset = Vector3.new(0, -1.5, 0)
if savedPersonHiding:FindFirstChild("Hidden") then
savedPersonHiding:FindFirstChild("Hidden"):Destroy()
end
if savedPersonHiding:FindFirstChild("CantHide") then
savedPersonHiding:FindFirstChild("CantHide"):Destroy()
end
if savedPersonHiding:FindFirstChild("InTable") then
savedPersonHiding:FindFirstChild("InTable"):Destroy()
end
end)
task.wait(0.75)
prompt.Enabled = true
Can = true
end
local function Destroy()
while not Can do
task.wait(0.175)
end
local savedPersonHiding = PersonHiding
h = false
Can = false
prompt.Enabled = false
prompt.ActionText = "Error"
PersonHiding = nil
lockerdoor.Anchored = false
lockerdoor.AssemblyLinearVelocity = lockerdoor.CFrame.LookVector * 150
local v = Instance.new("BoolValue")
v.Parent = locker
v.Name = "Destroyed"
v.Value = true
spawn(function()
if not savedPersonHiding then return end
if not savedPersonHiding:FindFirstChild("HumanoidRootPart") then return end
if not savedPersonHiding:FindFirstChildOfClass("Humanoid") then return end
savedPersonHiding:FindFirstChild("HumanoidRootPart").Anchored = false
savedPersonHiding:FindFirstChild("HumanoidRootPart").CFrame = part.CFrame * CFrame.new(0,0,-5)
savedPersonHiding:FindFirstChildOfClass("Humanoid").WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
savedPersonHiding:FindFirstChildOfClass("Humanoid").JumpPower = game.StarterPlayer.CharacterJumpPower
local anim = savedPersonHiding:FindFirstChildOfClass("Humanoid"):WaitForChild("Animator")
if anim then
local animation = Instance.new("Animation", anim)
animation.AnimationId = "rbxassetid://17371888743"
local animTrack = anim:LoadAnimation(animation)
animTrack:Play()
task.wait(0.001)
animTrack:Stop()
end
savedPersonHiding:FindFirstChildOfClass("Humanoid").CameraOffset = Vector3.new(0, -1.5, 0)
if savedPersonHiding:FindFirstChild("Hidden") then
savedPersonHiding:FindFirstChild("Hidden"):Destroy()
end
if savedPersonHiding:FindFirstChild("CantHide") then
savedPersonHiding:FindFirstChild("CantHide"):Destroy()
end
if savedPersonHiding:FindFirstChild("InTable") then
savedPersonHiding:FindFirstChild("InTable"):Destroy()
end
end)
end
local lockerEvent = locker.Event
lockerEvent.OnInvoke = function(action, arg1)
if action == "Enter" then
Enter(arg1)
elseif action == "Exit" then
Exit(arg1)
elseif action == "Destroy" then
Destroy()
end
end
spawn(function()
while task.wait(1) do
if PersonHiding then
if PersonHiding:FindFirstChildOfClass("Humanoid") then
if PersonHiding:FindFirstChildOfClass("Humanoid").Health <= 0 then
PersonHiding = nil
h = false
prompt.ActionText = "Enter"
end
end
if not PersonHiding:IsDescendantOf(game:GetService("Workspace")) then
PersonHiding = nil
h = false
prompt.ActionText = "Enter"
end
else
PersonHiding = nil
h = false
prompt.ActionText = "Enter"
end
end
end)
prompt.Triggered:Connect(function(plr)
if not plr then return end
if not plr.Character then return end
if not plr.Character:FindFirstChildOfClass("Humanoid") then return end
if plr.Character:FindFirstChildOfClass("Humanoid").Health <= 0 then return end
if not Can then return end
if PersonHiding ~= nil then
if plr.Character ~= PersonHiding then
return
end
end
if h == false then
lockerEvent:Invoke("Enter", plr.Character)
else
lockerEvent:Invoke("Exit", false)
end
end)
You did not need to send me the entire code… I am NOT reading all of that!
Okay sorry… But here’s a line:
character:FindFirstChildOfClass("Humanoid").CameraOffset = Vector3.new(0, -1.5, 0)
Note that the script is a server-script.
Have you tried with a local script maybe?
I tried the local script, But there is an error.
Try to put it in StarterGui then?
I solved it myself, anyways, Thanks!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.