Need help to fix "attempt to perform arithmetic (mul) on nil and number"

i was working on camera shake, well, trying to work on camera shake, there was no errors in the script, but says “attempt to perform arithmetic (mul) on nil and number” in the output, i was confused that what the hell causes the error?

b = (workspace.Camera.CFrame) * CFrame.Angles(0, 0, math.rad((math.random(-game.Workspace.Sound.PlaybackLoudness, workspace.Sound.PlaybackLoudness)) * workspace.Sound))
local hgf = (game.TweenService:Create(workspace.Camera, TweenInfo.new(0.15, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {
	CFrame = game.TweenService + Vector3.new(math.rad((math.random((-workspace.Sound.PlaybackLoudness) * 0.05, (workspace.Sound.PlaybackLoudness) * 0.05)) * 0.05), math.rad((math.random((-workspace.Sound.PlaybackLoudness) * 0.05, (workspace.Sound.PlaybackLoudness) * 0.05)) * 0.05), math.rad((math.random((-workspace.Sound.PlaybackLoudness) * 0.05, (workspace.Sound.PlaybackLoudness) * 0.05)) * 0.05))
})):Play()
local amount = workspace.Sound:FindFirstChild("Value")
if amount then
	amount= workspace.Sound.PlaybackLoudness
	if amount > workspace.Sound:WaitForChild("Value").Value then
		return 
	end
end

yep, its a poorly scripted camera shake i guess, i dont know nothing about camera shake, this is actually my first time scripting the camera shake.

2 Likes

In the first line you wrote:

Where you have: * workspace.Sound)) at the end. workspace.Sound is an Instance not a property value

Edit because I also noticed this: On this line you also did the same thing here:

You have CFrame = game.TweenService +, TweenService is also an Instance not a value

btw please research and learn how to write clean code, it would make debugging much easier both for yourself and for others helping you :slight_smile:

1 Like

Just going to toss in this LINK here is to one of the best camera shaking systems I’ve seen yet. I’ve even used this one in Unity (where it came from).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.