0
votes

Server Script has this piece of code in it. It occurs when a Player touches a brick...

game.workspace.CurrentCamera.CameraSubject = clone.Head

This piece of code works fine if run inside of Roblox studio. but when run from the roblox servers, does not work.

I understand why it does not work, because Current Camera must be changed from a Local script.. MY problem is that I can not find a way to call a Localscript from a Server script ...

I tried creating a function in a local script

function changeCameraSubj(newSubj)
    game.workspace.CurrentCamera.CameraSubject = clone.Head
end

but can not seem to call a LocalScript function directly form a server script ...

so my question is, what is the best way to call a function that must be performed in a LocalScript from a Server Script? I hav tried many vairations on the above, but nothing seems to communicate properly . Common sense would tell me that I need to create a custom server event that the local script can listen for, but I can not seem to find any way for that to work either.

Any help would be appreciated.

1

1 Answers

1
votes

I can't personally think of any reason why you would need to do this through a ServerScript; if possible, I'd recommend simply doing this through a LocalScript.

That said, if you must use a ServerScript for this, have your local code in a LocalScript, and trigger it on your ServerScript through a RemoteEvent. If you need a tutorial, there's a very informative guide here.