Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to change camera in FE game?

My script I made works perfectly in studio, but no in-game,I know its some sort of server-client thing but I can't figure out how to fix it!

The code runs when I execute a bindable event from a script in ServerScriptService, and this script is localscript inside StarterPlayerScripts.

camera = workspace.CurrentCamera

game.ReplicatedStorage.camera.camera1.Event:Connect(function()
	local target = workspace.Cameras.cam1
	camera.CameraType = Enum.CameraType.Scriptable 
camera.CameraSubject = target
    camera.CoordinateFrame = CFrame.new(target.Position)  
                           * CFrame.Angles(0, 6.25, 0) 
                           * CFrame.new(0, 0, 0)       

end)
game.ReplicatedStorage.camera.camera3.Event:Connect(function()
	local target = workspace.Cameras.cam3
	camera.CameraType = Enum.CameraType.Scriptable 
camera.CameraSubject = target
    camera.CoordinateFrame = CFrame.new(target.Position)  
                           * CFrame.Angles(0, 6.25, 0) 
                           * CFrame.new(0, 0, 0)       

end)

2 comments

0

if you want todo this locally you dont need an event

0

I've tried not locally with the same results

2 answers

It seems like that your structure is correct. The Client part is on the client, and the server part is on the server.

Now, the problem is that you've missed, that BindableEvent nor BindableFunctions communicate between the server and the client. Instead, if you fire a Bindable Object from a server script, other server scripts can receive it, and players dont. If you fire it from a client, the same goes on, execpt server does not receive it.

Obviously, that means you're using the wrong object to communicate between the server and the client. Which in this case should be a RemoteEvent instead of a BindableEvent.

So, just swap in your Bindable camera events with a remote event. and change to the event to listen to be "OnClientEvent". Then, on the server part, you can execute either using "FireClient(player)" or "FireAllClients()"

For more information, head to the roblox wiki :P https://wiki.roblox.com/index.php?title=API:Class/RemoteEvent

game.Workspace.CurrentCamera

5 comments

0

Use in localscript.

0

do you mean change "camera = workspace.CurrentCamera" to "camera = game.Workspace.CurrentCamera"?

0

Yeah. Global 'workspace' got deprecated recently. Use game.Workspace.

0

Accept answer pl0x

0
  1. 'workspace' is not deprecated. 'Workspace' is. and your answer completely makes no sense.

This discussion is preserved as it was. New answers, comments, and votes are closed.