Hiya,
I’m trying to make it so when you press the ProximityPrompt on the locker in my game, the player’s camera changes to a part inside the locker and their movement is locked. And when you press the ProximityPrompt again, it takes you back out.
How would I achieve something like this?
Below is my script so far, I just have no idea where to go from here and if this is even the right thing to do
--Variables
local part = script.Parent.LockerCamera
local db = false
local plr = game.Players.LocalPlayer:WaitForChild("Humanoid")
--Function
script.Parent.MetalDoor.Attachment.ProximityPrompt.Triggered:Connect(function(presser)
if presser ~= game.Players.LocalPlayer then
plr.
end
end)
Okay so you’re going to probably want to have a cameraPart inside of the locker where you want the camera to go when the player enters, so create a non collidable transparent part inside of the locker model and make sure it’s also anchored
Put this in a local script. Do note that this only changes the camera subject, it doesnt hide your character from anyone else, you would need some networking for that.
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character.Humanoid
local Camera = workspace.CurrentCamera
local Prompt = script.Parent.MetalDoor.Attachment.ProximityPrompt
local LockerCam = workspace.LockerCam
local origSpeed = Humanoid.WalkSpeed
local isHiding = false
local function camToLocker()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = LockerCam.CFrame
end
Prompt.Triggered:Connect(function(presser)
if not isHiding then
Humanoid.WalkSpeed = 0
camToLocker()
isHiding = true
else
Humanoid.WalkSpeed = origSpeed
Camera.CameraType = Enum.CameraType.Custom
isHiding = false
end
end)
Okay, so I’m not quite sure how other games put the player inside of the locker if it’s like too small because as you know if the locker is too small it’ll be clipping with the locker but one solution is to just anchor them while they are inside of the locker
local part = script.Parent.LockerCamera
local db = false
local plr = game.Players.LocalPlayer:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
--Function
script.Parent.MetalDoor.Attachment.ProximityPrompt.Triggered:Connect(function(presser)
local lockerCam : Part = 'PATH'
while (camera.CameraType ~= Enum.CameraType.Scriptable) do
camera.CameraType = Enum.CameraType.Scriptable
task.wait()
end
-- Set the camera's CFrame to the part's CFrame inside the locker
camera.CFrame = lockerCam.CFrame
end)
I suggest familiarizing yourself with studio first. Its hard for people to help without you knowing how to navigate around and pinpoint the problems in your code. From the looks of it, ‘MetalDoor’ is not in PlayerScripts (idk why it would be there), but thats why its erroring. Again, I have no context of metaldoor and its function in your script so I cannot help you without additional information.