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

I'm trying to make a sound play when a function is called but nothing happens. How do I fix?

Asked by
painzx3 43
9 years ago

So this is a local script and I put a "Sound" instance in it. So whenever a person double jumps, the sound is SUPPOSED to play but rather when I try it out, everything works okay but the sound doesn't play. How do I fix it??

Sound = game.StarterGui.DoubleJump.Sound
repeat wait() until Game:GetService("Players")
local Player = Game.Players.LocalPlayer

repeat wait() until Player

local FirstJump = false
local MidJump = false
local Mouse = Player:GetMouse()
TING = false
function onKeyDown(key)
if string.byte(key) == 32 and FirstJump == true and not TING and (MidJump == false or script.Creative.Value == true) then
TING = true
MidJump = true
Sound.Parent = game.StarterGui.DoubleJump
Sound.Pitch = 1
Sound.Volume = 0.5
Sound.SoundId = "rbxassetid://187137496"
Sound:Play()
Player.Character.Torso.Velocity = Vector3.new(0,50,0)
wait(0.1)
TING = false
Sound:remove()
end
end

function Update()
if Player.Character.Humanoid.Jump == true then
FirstJump = true
else
FirstJump = false
MidJump = false
end
end

Mouse.KeyDown:connect(onKeyDown)
Player.Character.Humanoid.Changed:connect(Update)

Answer this question