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)
You are indexing two different RemoteEvents from ReplicatedStorage.
In your LocalScript, you are listening to "RockShake," but on the server you are calling FireAllClients() on a remote called "Shake." I am not sure if you had your output open when you were testing.
Besides that, it seems you are using FireAllClients incorrectly. If the client listens to the event, you don't need to pass their humanoid in as an argument. Just use the client's humanoid. You also do not need to loop through every player to FireAllClients. By doing so, you will fire all clients multiple times, which I assume is not what you were trying to do.
--//Server Script local players = game.Players:GetChildren() local remote = game.ReplicatedStorage.Shake --Change as necessary remote:FireAllClients()
--//Local Script game.ReplicatedStorage.Shake.OnClientEvent:Connect(function() local humanoid = game.Players.LocalPlayer.Character.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)