How to make button that force views everyone

hello so i was wondering how would you make it so that when a person presses a button it would lock everyone in the games screen in a certain position for a specific amount of time (like maybe 3 minutes?)

ive already made a functioning open and close ui with some other button commands just cant seem to make this one button work

Whatdo you mean with screen? Their camera?

yeah i meant their camera sorry for the bad wording

No worries. Pretty easy to do. 3 minutes is very long though!

local cam = workspace.CurrentCamera cam.CameraType = Enum.CameraType.Fixed

That’ll freeze someone’s camera. Run this on a local script.

1 Like

Im not quite sure what you mean by

But if you mean camera you can use a remote and fireallclients whenever a person presses said button. Inside of the playerscripts you can place a local script and do the scripting there. Here is an example that I made.

---// Button Script - Put inside of button
local button = script.Parent.ClickDetector -- whatever the path to your button is. That is if its a click detector
local remote = game.ReplicatedStorage.RemoteEvent -- the path to the remote to fire

button.MouseClick:Connect(function()
    remote:FireAllClients()
end)

Next is the local script inside of the StarterPlayerScripts

---// Put script inside of StarterPlayerScript
local remote = game.ReplicatedStorage.RemoteEvent -- the path to the remote to fire

remote.OnClientEvent:Connect(function()
    local camera = workspace.CurrentCamera
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = workspace.position.CFrame
end)

What this would do is that whenever you press the button it changes the currentcamera CFrame to the desired parts CFrame. To reset this you can do

camera.CameraType = Enum.CameraType.Custom
1 Like

It says this:

image

Make the button script server script.

To confirm, are you talking about a ClickDetector placed in an actual button in the workspace, or a ImageButton/TextButton?

I’m talking about a text button.

In this case, instead of a remote event, use a bindable event. They are similar to remote events but they use client to client and server to server communication.

Instead of a remote event you can use a remote function

Regardless of the method you use to achieve this there is no way to have your client fire for every single client without first going through the server to fire for every single client (player) in the game.

Considering you want this for every single client, you could in theory FireServer from the client, do some anti exploitive checks (ie. is the person actually suppose to have access to the button), and then use the :FireAllClients from the server side. I made something like this awhile ago for a training center and I think I did something along the lines of that. I’d recommend exploring the other options in this post however to find the best option suited for your needs. RemoteFunctions are one option.

1 Like

ive been playing with it for a few minutes now to get rid of this error but it still says this

Apparently, you’re trying to look for the remote function inside of the remote function. instead, do.

local remoteFunction = game.ReplicatedStorage:WaitForChild("RemoteFunction")

Unless the “RemoteFunction” is a folder, and the remote function is inside the remote function folder.

Hello, sorry for the delayed response. I’ve made it work, and now I am trying to make the camera face a certain position. I could technically use “camera.Focus = FocusPart.CFrame” however when I try it like that it puts the camera in a different angle and I want it to be the same angle everytime.

This is what I have:
image

When I try that, this appears:
image

.Focus is used for parts, not strings. Also if you use the method I used you can adjust the part to face wherever you want it to face.

You should learn basic Lua before trying to code a cafe from scratch.

1 Like

It gives me this error.

Make sure the path to “RemoteFunction” is right.
Also, you should take his advice.

i am honestly just doing this because a decent scripter can cost more than 15k. plus ive already scripted the cafe im just working on some features in the training center, ive already scripted most of them, this is just the last one i need to work.