Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sound is not a valid member of tool. WHAT??? [Answered]

Asked by
Clorize 31
5 years ago
Edited 5 years ago

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.

local tool = script.Parent
local character = tool.Parent
local sound = tool.Sound
local debounce = false
local on = false
local aura = tool.ParticleEmitter


tool.Activated:Connect(function()
    if debounce == false then
        debounce = true
        if on == false then
            on = true
            local soundclone = sound:Clone()
            local auraclone = aura:Clone()
            soundclone.Name = "Kaioken"
            auraclone.Name = "Kaioken"
            soundclone.Parent = character.Torso
            auraclone.Parent = character.Torso
            soundclone:Play()
            debounce = false
        else
            local children = character.Torso:GetChildren()
            for i = 1, #children do
                print(i, children[i].Name)
            end
        end
    end
end)

0
either the issue is what sonysunny said, or your sound actually isnt loaded by the time the script runs. try using :WaitForChild() Gey4Jesus69 2705 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago

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:

local sound = tool:FindFirstChildOfClass("Sound")

As follows:

local tool = script.Parent
local character = tool.Parent
local sound = tool:FindFirstChildOfClass("Sound")
local debounce = false
local on = false
local aura = tool.ParticleEmitter


tool.Activated:Connect(function()
    if debounce == false then
        debounce = true
        if on == false then
            on = true
            local soundclone = sound:Clone()
            local auraclone = aura:Clone()
            soundclone.Name = "Kaioken"
            auraclone.Name = "Kaioken"
            soundclone.Parent = character.Torso
            auraclone.Parent = character.Torso
            soundclone:Play()
            debounce = false
        else
            local children = character.Torso:GetChildren()
            for i = 1, #children do
                print(i, children[i].Name)
            end
        end
    end
end)

0
Please mark your question as answered if I solved your problem! checkerscat2 116 — 5y
0
im not 100% sure about this, but i dont think that will work with 2 sounds Clorize 31 — 5y

Answer this question