So, I'm trying to pass a number value from the server to the client, but when it goes to the client, it prints out as nil.
Server Script:
local function Explode(Player, ExplosionPart, ExplosionSize, ExplosionTime) local Explosion = game.ServerStorage.Explosion:Clone() Explosion.Parent = workspace Explosion:SetPrimaryPartCFrame(ExplosionPart.CFrame) if ExplosionSize > 100 then local Time = 5 game.ReplicatedStorage.Events.ShakeCamera:FireAllClients(Time) print("Camera Shake Event Fired") end --other code end
Local Script:
local runService = game:GetService("RunService") local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local function ShakeCamera(Player, Time) local function updateBobbleEffect() local currentTime = tick() local bobbleX = math.cos(currentTime * 10) * 5 local bobbleY = math.abs(math.sin(currentTime * 10)) * 5 local bobble = Vector3.new(bobbleX, bobbleY, 0) humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.1) end local CameraShaker = runService.RenderStepped:Connect(updateBobbleEffect) wait(Time) CameraShaker:Disconnect() end game.ReplicatedStorage.Events.ShakeCamera.OnClientEvent:Connect(ShakeCamera)
OnClientEvent does not have a parameter for Player. Player is actually the Time, which is why Time is nil. So remove Player.
local runService = game:GetService("RunService") local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local function ShakeCamera(Time) local function updateBobbleEffect() local currentTime = tick() local bobbleX = math.cos(currentTime * 10) * 5 local bobbleY = math.abs(math.sin(currentTime * 10)) * 5 local bobble = Vector3.new(bobbleX, bobbleY, 0) humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.1) end local CameraShaker = runService.RenderStepped:Connect(updateBobbleEffect) wait(Time) CameraShaker:Disconnect() end game.ReplicatedStorage.Events.ShakeCamera.OnClientEvent:Connect(ShakeCamera)
Hope this helps!