Attempt to index number with 'Octave' | SoundEffect Error

So, i try to make a command for set the pitch of a SoundEffect but i have this error and i don’t know why
image
The code

commands.pitch = function(sender, arguments)
	if isAdmin(sender) then
		local pitch = arguments[1]
		if pitch then
			if tonumber(pitch) > 2 then
				SendClientNotification:FireClient(sender, "Pitch", "Max pitch is 2")
				else
				local MusicPlayerPitch = game.Workspace:WaitForChild("MedStudioMusicPlayer").Pitch
				MusicPlayerPitch.Octave = tonumber(pitch)
				SendClientNotification:FireClient(sender, "Pitch", "Pitch set to"..pitch)
			end	
		end
	end
end

I have the impression that it does not detect pitch but yet it is the good parent

What value (or at least the data type) did you except for MusicPlayerPitch? It looks like the value for MusicPlayerPitch is a double (number) reading the error message.

Is string 1.5 converted to number so is 1.5

The problem still here :confused: after checking everything is correct so I don’t understand

No what’s the value of the MusicPlayerPitch, not the value of a pitch?
You’re indexing a double (number) with Ocatve.
Try printing to see what value is it

print(MusicPlayerPitch);

Does it print out a double (number) value? If it does then that’s the problem.

1 Like

My script is gone, I’m going to see the online backup, it’s going to take a while sorry

Edit i dont have update…

huhh okay this will take a moment i need to recode the part of script i have deleted

Okay @Blockzez , so this is what is say
image
(Yes i used new variable srr)

This is the tonumber output

Can you show what MedStudioMusicPlayer is in Explorer?

Yes, 30 character yeeeeeeeeeeeeeee
image

And what is the class name of Pitch?

Is PitchShiftSoundEffect
30 characterrrrrrrrr

Maybe the Pitch instance isn’t there? I replicated on how you do chat commands, and it is working for me.

Yes, is here :confused: it should work because me too it is there and it is not a problem of the studio because that does not work on roblox either, I can see your script has you and how to aver you to place all?

Just a simple PlayerAdded and Chatted event:

game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local number = tonumber(msg)
if number then
print(type(number)) -- prints out number
path_to_pitchshift.Octave = number
end
end)
end)

huh, this is strange for my is not work,

script.MedStudioMusicPlayer.Parent = game.Workspace -- Music System
local MedStudioMusicPlayer = game.Workspace:WaitForChild("MedStudioMusicPlayer")
MedStudioMusicPlayer.Pitch.Octave = 2

this is the script the problem ?

Here are my assumptions:

  1. PitchShifter doesn’t exist.
  2. Invalid number (either it’s nil or a string)
  3. You didn’t put a WaitForChild("Pitch")
1 Like

@Quwanterz i try 1 and 2
i used Direct path, so im sure is the good path

game.Workspace.MedStudioMusicPlayer.Pitch.Octave = 2

and i used directly 2 and i have the error…

Change local MusicPlayerPitch = game.Workspace:WaitForChild("MedStudioMusicPlayer").Pitch to local MusicPlayerPitch = game.Workspace:WaitForChild("MedStudioMusicPlayer"):WaitForChild("Pitch")

1 Like

Man… the solution 3 work… Thx nvm xD

1 Like

Just for clarity, chaining too many WaitForChild s is bad practice,

 local MusicPlayerPitch = workspace:WaitForChild("MedStudioMusicPlayer", 5).Pitch

It’s just inefficient, take recommendations of the Developer Hub and other developers.