I’ve tried multiple fixes, such as replacing variables with their non-variable counterparts (if that makes sense).
Basically, when the player dies, the magnitude of HumanoidRootPart and Origin (origin being where the screen shake is originating from, it IS a vector3 position) becomes 200-300. So, I thought “Okay, this is the issue.”
Although it clearly IS a part of the issue, it isn’t the whole issue. When I brought the player over to the area that the script thought was correct, the screen shake STILL didn’t work.
Is there any obvious issue with my code? If not, do you have any hypotheses?
local function screenShake(Origin, Range, Intensity, shakeCount)
print(Origin, Character:FindFirstChild("HumanoidRootPart").Position, (Origin - Character:FindFirstChild("HumanoidRootPart").Position).Magnitude)
if (Origin - HumanoidRootPart.Position).Magnitude > Range then return end
spawn(function()
for i = 1, shakeCount do
Humanoid.CameraOffset = Vector3.new(math.random(-5 - Intensity + i/10, 5 + Intensity - i/10), math.random(-5 - Intensity + i/10, 5 + Intensity - i/10), math.random(-5 - Intensity + i/10, 5 + Intensity - i/10))
runService.Heartbeat:Wait()
end
Humanoid.CameraOffset = Vector3.new(0,0,0)
end)
end```