Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script says `explosion` is only in enclosing function; consider changing it to local?

So in my game, there is a script but it gives me this warning My script says explosion is only in enclosing function; consider changing it to local? What should I do? Heres a piece of the script

function blowUp()
	local sound = Instance.new("Sound")
		sound.SoundId = "rbxasset://sounds\\Rocket shot.wav"
		sound.Parent = script.Parent
		sound.Volume = 1
		sound:play()
	explosion = Instance.new("Explosion") -- here is the part where it gives the warning
	explosion.BlastRadius = 6
	explosion.BlastPressure = 10000000 

I am hoping that someone could answer my question.

1 comment

0

It isn't an error. It's a warning which tells you to add "local" before "explosion"

1 answer

✓ Accepted answer

It's just a warning telling you that since you don't use the variable outside of the function you should consider changing it to local since it's better for performance

This discussion is preserved as it was. New answers, comments, and votes are closed.