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

Camera changes for every player instead of the one touching the part. What's the problem?

Asked by 6 years ago
01local shopPart = game.Workspace.BackpackPlatform
02 
03local function onTouch(partTouched)
04    local prevCFrame = game:GetService("Workspace").Camera.CFrame
05    local camType = game:GetService("Workspace").Camera.CameraType
06    local price = script.Parent.Price
07    local spaces = script.Parent.Spaces
08 
09 
10    game:GetService("Workspace").Camera.CameraType = camType
11    game:GetService("Workspace").Camera.CFrame = prevCFrame
12 
13    function MoveCamera(cframe, button)
14 
15    game:GetService("Workspace").Camera.CameraType = Enum.CameraType.Scriptable --Disables player moving camera
View all 36 lines...

So, when a player touches the shopPart, the camera changes for every player, is there a way to change it only to the player touching the part?

0
Is this in a LocalScript? it should be... Make sure FilteringEnabled is on, and change "Camera" to "CurrentCamera" SerpentineKing 3885 — 6y
0
Yes it is in a localscript, and FE is on. I'll try to change it to CurrentCamera and see if it works, thanks ady1111 8 — 6y
0
Working! Thank you very much! ady1111 8 — 6y
1
wow. did I just got my months old question, "Why do you type CurrentCamera and not Camera?"`answered? sydre 229 — 6y
View all comments (2 more)
0
lol, ur welcome! SerpentineKing 3885 — 6y
0
Yeah use a LocalScript. songboy50 77 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Necessary Items:

A. FilteringEnabled set to true

This is to make sure that the game doesn't replicate all changes on the client to the server, making each player's changes unique (so if you died and the camera was reset it would not reset for all players)

B. Using a Local Script

To change a player's camera you must use a LocalScript since the camera is unique to each player, and changes to the server camera will not replicate (as it is not the same instance)

C. Using CurrentCamera

The workspace has an instance called "CurrentCamera" which on the client serves as the directional framing of the player's movement. The Camera cannot be directly edited from the server since the current camera is only local.

EXAMPLE

Change

1game:GetService("Workspace").Camera

to

1game:GetService("Workspace").CurrentCamera

For more on the Camera, see the below link:

https://developer.roblox.com/api-reference/class/Camera

Ad

Answer this question