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

Why does nothing in this camera manipulation script work in online mode?

So I made this simple function that triggers when someone that is a certain rank or above chats the command. Works flawlessly in test servers, even got a few officers in my group to join and test it to make sure it wasn't working just for me for some odd reason. Yet nothing in it functions in online servers

local status=game.ServerStorage.active
local cam=game.Workspace.cam

local function onDeploy()
	local music=game.Workspace.sounds.deploy
	local c=game.Workspace.Camera
	music:Play()
	c.CameraType="Scriptable"
	c.CameraSubject=cam
	c.CFrame=cam.CFrame
	print("done")
end


status.Changed:connect(onDeploy)

Basically the another script waits for an officer to chat "!deploy", when he does that it sets an intvalue from 0 to 1. This script waits for that intvalue to be changed and triggers the function.

There are no errors and it's looping completely throiugh because the console prints done even in online servers. But the music/camera manipulation doesn't work at all

2 comments

0

Got the music playing, just needed to move it to workspace from serverstorage (lol)

0

Is your game filtering enabled?

1 answer

✓ Accepted answer

The fact that you are trying to access a child of ServerStorage leads me to believe that you are running this code in a server-sided script. Keep in mind that server-sided scripts should not be manipulating players' cameras; tasks like these should only be run by local scripts.

One way to fix your code would be to move the camera-manipulating part of your code to a local script that is provided to each player. To accommodate this, you should also move game.ServerStorage.active to game.ReplicatedStorage so your local script can access the status object. The code that plays the sounds should still be a server-side script.

[EDIT] The preferable way to access a player's camera via local script is by using theworkspace.CurrentCamera property, not by accessing the camera object directly by workspace.Camera.

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