By server sided I mean how can I make the camera shake for everyone in the game when a specific function happens, I've already attempted to use OnClientEvent() and FireAllClients() to achieve this but to no avail, but I'm not 100% sure what I'm doing wrong if I am doing it wrong.
Any help will be much appreciated.
Here is the code I have so far:
--//Server Script
local players = game.Players:GetChildren()
local remote = game.ReplicatedStorage.Shake
for i,v in pairs(players) do
local char = v.Character
local Humanoid = char:WaitForChild("Humanoid")
remote:FireAllClients(Humanoid)
end
--//Local Script
game.ReplicatedStorage.RockShake.OnClientEvent:Connect(function(humanoid)
for i = 1, 20 do
local x = math.random(-100,100)/100
local y = math.random(-100,100)/100
local z = math.random(-100,100)/100
humanoid.CameraOffset = Vector3.new(x,y,z)
wait()
end
end)

11 comments
I also forgot to mention, it only works for me but no one else, I was also reported it worked for like a split second.
But thank you very much, I will attempt this tomorrow since I have to go somewhere now.
I tested it and it seemed to be working for about 1-2 seconds. If you want it to be longer then you need to set a bound higher than 20.
That much I know, but I’m not 100% sure it will work for everyone else in the game. Are you able to access all of the clients’ humanoids using FireAllClients and OnClientEvent?
I don't think I understand what you are saying very well. When you are doing FireAllClients(), each player connects the shake function to the OnClientEvent, meaning everyone will shake their own screens. Is there something else you were trying to do?
Nope, that’s all I wanted to do, I was just wondering if the parameter for the FireAllClient() were all of the players. Thanks for clearing up my confusion.
Oh okay lol. Yeah, FireAllClients() will fire the event for all clients, meaning each client will connect that function to the listener at the same time.
Alright, thanks a bunch, I tried looking for this somewhere but wasn't completely certain.
I've just ran into a predicament , I tried indexing character using players as the parameter and it says it is attempting to index nil, what I'm trying to do is get EVERYONES character and humanoid, and apply the cameraoffset to all of them. It's just I can't reference every ones humanoid which is needed for this specific script.
Camera effects should usually be done on the client, as the camera is unique to each client. Why are you trying to get everyone's humanoid instead of firing all clients?
Because I need to affect all of the humanoid's CameraOffset so it happens to everyone at once. For example, if I was to throw a projectile, and it hit something , I would want the screen to shake for everyone, also when I fire all clients, as you can see in my script, I need to reference the humanoid but I can't even reference the player to even get to the humanoid, how else would I do it?