Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ANSWERED How do I make it so the player cant move the camera and also lock someone into a seat? [closed]

Asked by 6 years ago
Edited 6 years ago

I am working on a project that is like a waiting simulator, and I need this code!

Thanks!

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 6 years ago

Hi promaster1111,

You can stop the player from moving their camera by just turning the CameraScript off. This script is located in PlayerScripts under the Player. So, its specific location is:

Players > Player > PlayerScripts > CameraScript

Just disable that script. So, the code would look something like this:

Local Script Inside StarterGui

local players = game:GetService("Players");
local player = players.LocalPlayer;
local cam_script = player:WaitForChild("PlayerScripts"):WaitForChild("CameraScript");

cam_script.Disabled = true;

As for how to make players sit in a seat, I recommend disabling the control script, so that players can't control the Character, and then teleporting them to the seat. So, the ControlScript is located in PlayerScripts as well. It's specific location is:

Players > Player > PlayerScripts > ControlScript

Just disable that script and you should be able to restrict the Players' movement, and then you just teleport the player to the seat using CFrame. Here's how it would look in code.

Local Script Inside StarterGui

local players = game:GetService("Players");
local player = players.LocalPlayer;
local char = player.Character or player.CharacterAdded:Wait();
local root = char:WaitForChild("HumanoidRootPart");
local seat = workspace.Seat; -- This is the seat.
local control_script = player:WaitForChild("PlayerScripts"):WaitForChild("ControlScript");

control_script.Disabled = true;
root.CFrame = seat.CFrame;

Hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

0
Btw, if you want to allow players to be able to move again and move their camera, just make the scripts' Disabled property false. KingLoneCat 2642 — 6y
0
Good answer. kees31ALT 5 — 6y
0
Thanks. KingLoneCat 2642 — 6y
0
Thanks! promaster11111 -8 — 6y
View all comments (4 more)
0
No problem. KingLoneCat 2642 — 6y
0
Wait, should local seat = workspace.Seat; have a capital W? promaster11111 -8 — 6y
0
Wait, YOU SPELLED MY NAME WRONG?! I'M SO MAD RIGHT NOW! YOU FORGOT A 1! promaster11111 -8 — 6y
0
Never use capital W when addressing just the workspace. You don't need to use it unless you're doing like game.Workspace. But, you can just say workspace. Also, sorry for the misspell. Usually I use the first part of peoples' name not the whole thing. KingLoneCat 2642 — 6y
Ad