I need a script for my closet door

So, I been trying to make a script for a hiding spot inside a closet, I tried with Code Assist because I’m not best at scripting those, so I need some help.

This is what I got all I need is some scripts, one script makes the hiding animation of the camera with outside Cam and inside Cam and the other scripts make the sound effects work.


i appreciate any help! thanks for your time!

1 Like

So firstly, your camera script is a server-script so this would affect everyone’s camera. And I assume you want to only affect the player’s camera who opened the closet right? So make a local script parented to startercharacterscripts and here’s some code. We will also need some remote events, so make a remote event and parent it to replicatedstorage.

-- Make this a server script (basically the same type of script you made the "Handler" script) and parent it to serverscriptservice
local ProximityPrompt = workspace.Lockers.Doors.promptpart
local RE = game.ReplicatedStorage.RemoteEvent -- Create a remote event in replicatedstorage for this to work please
ProximityPrompt.Triggered:Connect(function(player)
workspace.Locker1.Locker2.Handle2.Position = -- I just guessed which parts in the locker you want to close but you know which one you do want to. Then just set do = Vector3.new(x,y,z) You need to put numbers in the brackets but I'm just showing you what those values represent. I hope you know what these coordinates mean from minecraft or something.
RE:FireClient(player)
end)
-- Local script (parent this to startercharacterscripts which is in starterplayer)
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent") -- Parent a remote event object in replicated storage for this to work
RE.OnClientEvent:Connect(function()
local camera = workspace.CurrentCamera -- gets the local player's camera
camera.CFrame = -- this will change the position of the camera, you can change the position because I don't know where you want to put it at and where in game. To change it you just do camera.CFrame = workspace.Part.CFrame for example (so you're inside or outside camera part things you made), or you can do CFrame.new(0,2,0) for example. Don't actually do that these are just examples.
end)

I couldn’t give you everything but hey it’s better than nothing am i right? Atleast you’re now changing the player’s camera and you’re able to change the player’s locker door position part thing.

2 Likes

thanks! this could be the base of my script, i could add more things, also, i wanted to see how could i make the humanoid enter inside, (the doors open and close)

thats the part with most issues i had, opening doors with scripts

No problem, you do know how cframes/vector3s work right? It would be alot easier if you did, if you also wanted to add a transition to the doors closing you’d need to use lerp or TweenService I’ll link you the documentation if you need it to learn about these.

I kind of know how they work, I had many problems opening a door for an entrance, as an output, it moved really far away and hard to control, I also made a post for that problem I had, I can send the link if you want to see what I mean.

I would love to help but I am kinda busy, hopefully someone comes to your topic later to help. Sorry, try looking up on the documentation/devforum about tweenservice/lerping and cframes/vector3s.