Script works in Roblox Studio, but not ingame

Hello, while testing one of my projects and looking through the developer console, I noticed that a script appeared to work in studio, but not ingame, printing this error message :

thing

The error message is talking about this part of the script :

function newWave()
	if allowNextWave == true then
	if wave > #script:GetChildren() then
			wave = 1
		else
			wave = wave + 1
		end
        shared.WaveNotif(wave)
        local sound = Instance.new("Sound",workspace)
		sound.SoundId = "rbxassetid://5980011923"
		sound.Volume = 3
		sound:Play()
		spawnEnemy(require(script[wave]))
		debris:AddItem(sound,10)
	end
end

The script is meant to be a zombie wave script, but it affects specifically this line :

shared.WaveNotif(wave)

It only affects this line, the conditional branch above it remains unaffected. I’ve tried turning the “wave” value into a NumberValue instance but that didn’t work either. Can anybody atleast give me an idea of what’s happening?

1 Like

This error simply means that you tried to call a function which doesn’t exist. Make sure you created the function and didnt assign a different value to it.

2 Likes

Looking through the scripts, it appears that the function does actually exist, it’s just that for some reason it only works inside of Studio, and not ingame.

shared.WaveNotif, where was this declared?

Consider using ModuleScripts instead, as there are timing issues between scripts executing in different orders:

1 Like

The ModuleScript fixed it, thanks alot!

1 Like