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

Sound Script For Tool Not Working!? Trying To Play Sound On The Server

Asked by 4 years ago

I'm trying to get an "Eat" sound to be played, but it doesn't seem to work? Any ideas why?

Local Script

local animations = {"4614299228"}
local CanAttack = true

local Player = game:GetService'Players'.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:FindFirstChild("Head")
local throw= Instance.new("Sound",Head)
throw.SoundId="rbxassetid://430285057"

script.Parent.Activated:connect(function()
    if CanAttack == true then
        CanAttack = false
    local animation = Instance.new("Animation",  script.Parent.Parent)
    animation.AnimationId = "http://www.roblox.com/asset?id="..animations[math.random(1, #animations)]
    local chosenanim = script.Parent.Parent.Humanoid:LoadAnimation(animation)
    chosenanim:Play()
    throw:Play()
    wait(.5)
    script.Parent.Handle.Transparency = 1
    wait(.5)
    throw:Stop()
    wait(1)
    script.Parent.Handle.Transparency = 0
    CanAttack = true
    end
end)
0
This is a server or local script? Are any errors thrown? compUcomp 417 — 4y
0
No errors thrown and it's a LocalScript Within A Tool Jomeliter 55 — 4y

1 answer

Log in to vote
0
Answered by
Markdrg 15
4 years ago

Try making another script and putting the sound stuff.

l
local Head = Character:FindFirstChild("Head")
local throw= Instance.new("Sound",Head)
throw.SoundId="rbxassetid://430285057"

script.Parent.Activated:connect(function()

    throw:Play()
    wait(.5)
    script.Parent.Handle.Transparency = 1
    wait(.5)
    throw:Stop()
    wait(1)
    script.Parent.Handle.Transparency = 0

    end
end)

If that doesnt work, try making a sound and putting the soundid in it and just play it in the script. instead of making a new sound.

Ad

Answer this question