I made this script for a tool with a sound and particle emitter in the tool
when ever i activate the tool, i get the error "Sound is not a valid member of tool" is there anything wrong with the script? (The error sends me to line 3 by the way)
Edit: The solution was to add ":WaitForChild()" as the sound didn't load in time.
01 | local tool = script.Parent |
02 | local character = tool.Parent |
03 | local sound = tool.Sound |
04 | local debounce = false |
05 | local on = false |
06 | local aura = tool.ParticleEmitter |
07 |
08 |
09 | tool.Activated:Connect( function () |
10 | if debounce = = false then |
11 | debounce = true |
12 | if on = = false then |
13 | on = true |
14 | local soundclone = sound:Clone() |
15 | local auraclone = aura:Clone() |
The problem here is that you've named "Sound" to something else. Or "Sound" isn't even in the tool at all.
Check in the explorer and see what "Sound" is named too. (if it was called Namo it would be "local sound = tool.Namo") and if the Sound object doesn't exist just create one.
There is nothing wrong with the script. However, you may need to add your own sound to the tool.
Make sure to name it "Sound", as that is what the script is looking for.
Or, if there's already a sound in the tool, rename it to "Sound", or change line 3 to:
1 | local sound = tool:FindFirstChildOfClass( "Sound" ) |
As follows:
01 | local tool = script.Parent |
02 | local character = tool.Parent |
03 | local sound = tool:FindFirstChildOfClass( "Sound" ) |
04 | local debounce = false |
05 | local on = false |
06 | local aura = tool.ParticleEmitter |
07 |
08 |
09 | tool.Activated:Connect( function () |
10 | if debounce = = false then |
11 | debounce = true |
12 | if on = = false then |
13 | on = true |
14 | local soundclone = sound:Clone() |
15 | local auraclone = aura:Clone() |