i Want Camera to shake when the Distance is low
it doesn’t work
i tried looking dev forum but none helped me
server:
for _, player in pairs(game.Players:GetPlayers()) do
local Distance = (script.Parent.Parent.HumanoidRootPart.Position - player.Character:WaitForChild("HumanoidRootPart").Position).Magnitude
if Distance <= 150 then
game.ReplicatedStorage.Remotes.Camera_Shake:FireClient(player)
end
end
Local Script:
game.ReplicatedStorage.Remotes.Camera_Shake.OnClientEvent:Connect(function(player)
while true do
local x = math.random(-100,100)/100
local y = math.random(-100,100)/100
local z = math.random(-100,100)/100
player.Character:WaitForChild("Humanoid").CameraOffset = Vector3.new(x,y,z)
wait(0.1)
end
end)
Did You check the output? You might have errors here, espcially if we are talking about Your local script. In the local script You don’t use WaitForChild method. Secondly modify the server script to check if the distance is lower for anyone:
for _, player in pairs(game.Players:GetPlayers()) do
local Distance = (script.Parent.Parent.HumanoidRootPart.Position - player.Character:WaitForChild("HumanoidRootPart").Position).Magnitude
if Distance <= 150 then
print("Low distance!")
game.ReplicatedStorage.Remotes.Camera_Shake:FireClient(player)
end
end
Lastly if this is the whole server script keep in mind that the distance is being checked only once, as soon as the server scripts loads and never again.