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

Help:"Global 'Name' is only used in the enclosing function; consider changing it to local"?

I was trying to fix a script that was apart of a free model and I was wonder how I can solve this error with the section of the script that I have provided:

function PlaySound(Sound,RChr)

SEs.FireClient:FireServer(k,"PlaySound",Sound,RChr)

local newSound = Instance.new("Sound", Sound.Parent)

newSound.SoundId = Sound.SoundId

newSound.PlaybackSpeed = Sound.PlaybackSpeed

newSound.Volume = Sound.Volume

newSound.Name = Sound.Name.."Playing"

newSound:Play()

game:GetService("Debris"):AddItem(newSound, Sound.TimeLength)

end

1 comment

1

I don't believe you have provided the correct script, the error does not have anything to do with any of the code you provided. Also, that message is not an error, it's a warning. If you localize variable 'Name', it should go away.

1 answer

✓ Accepted answer

Hello, you can fix this warning by adding "local" before any variables with it. EX:

function hi() Var1 = "I like coding!" end

should really be:

function hi() local Var1 = "I like coding!" end

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