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

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

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)

2 comments

0

This is a server or local script? Are any errors thrown?

0

No errors thrown and it's a LocalScript Within A Tool

1 answer

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.

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