Howdy!, I am making a simple game and I have tried to do a local sound when you touch a part, however, I have not yet come to a conclusion, and I have thrown all attempts throught the window, so I am asking for help to someone more experienced that I am.
There isn't anything related to sound, yet, but I will post this code, as it might change how the sound should be made.
-- / Variables / --
local Debounce = false
-- / When Eaten / --
script.Parent.Touched:Connect(function(Plr)
if Plr.Parent:FindFirstChild('Humanoid') and Debounce == false then
local Humanoid = Plr.Parent:FindFirstChild('Humanoid')
Debounce = true
local Body1 = Humanoid:FindFirstChild('BodyDepthScale')
local Body2 = Humanoid:FindFirstChild('BodyWidthScale')
local Body3 = Humanoid:FindFirstChild('BodyHeightScale')
local Head = Humanoid:FindFirstChild('HeadScale')
Body1.Value = Body1.Value + .03
Body2.Value = Body2.Value + .025
Body3.Value = Body3.Value + .02
Head.Value = Head.Value + .015
Humanoid.WalkSpeed = Humanoid.WalkSpeed - 0.01
Humanoid.JumpPower = Humanoid.JumpPower - 0.031
script.Parent:Destroy()
end
end)
wait(10)
script.Parent:Destroy()
This one is the part script at ServerStorage that I want to make the local sound, and is cloned by a ServerScriptService Script.
If you could help me by either a script or an Idea that I haven't tried, I'll be happy to try it!
Best Regards - A novice scripter.
I did it!, Thanks to all of you, but especially to UnitedGateCompany, who assisted me with their time and effort to help make my own game.
If any of you have a similar problem, I will post the now working script below.
-- / Variables / --
local Debounce = false
-- / When Eaten / --
script.Parent.Touched:Connect(function(Chr)
if Chr.Parent:FindFirstChild('Humanoid') and Debounce == false then
local Humanoid = Chr.Parent:FindFirstChild('Humanoid')
local Player = game.Players:GetPlayerFromCharacter(Chr.Parent)
Debounce = true
local Body1 = Humanoid:FindFirstChild('BodyDepthScale')
local Body2 = Humanoid:FindFirstChild('BodyWidthScale')
local Body3 = Humanoid:FindFirstChild('BodyHeightScale')
local Head = Humanoid:FindFirstChild('HeadScale')
Body1.Value = Body1.Value + .03
Body2.Value = Body2.Value + .025
Body3.Value = Body3.Value + .02
Head.Value = Head.Value + .015
Humanoid.WalkSpeed = Humanoid.WalkSpeed - 0.01
Humanoid.JumpPower = Humanoid.JumpPower - 0.031
script.Parent.Transparency = 1
local Sound = script.EatSound
Sound.Parent = Player
Player:WaitForChild('EatSound')
Sound:Play()
wait(Sound.TimeLength)
Sound:Destroy()
if Player.EatSound ~= nil then
wait(Player.EatSound.TimeLength)
Player.EatSound:Destroy()
end
script.Parent:Destroy()
end
end)
wait(10)
script.Parent:Destroy()

3 comments
so you want a sound to play locally?
If you want the sound to play separately for each client, use Sound:Play() in a Local Script (where Sound is the Audio).
or just put it in the players "PlayerGui"