I have made a part that when touched will make you take damage and play a sound but the problem is that the sound is not working despite Sound.IsPlaying returning true and the IsPlaying box in the sound properties isn’t set to true during this which is weird
This is the script:
Script
local SoundService = game:GetService("SoundService")
local killpartsound = SoundService:WaitForChild("killpartsound")
local killpart = game.Workspace.killpart
local canTouch = true
local touchedCooldown = 5
killpart.Touched:Connect(function(Hit)
local plrHumanoid = Hit.Parent:FindFirstChildOfClass("Humanoid") or Hit.Parent.Parent:FindFirstChildOfClass("Humanoid")
if plrHumanoid then
if canTouch then
canTouch = false
local damage = math.random(10,90)
if not killpartsound.IsLoaded then
killpartsound.Loaded:Wait()
end
plrHumanoid.Health -= damage
killpart.Color = Color3.fromRGB(77, 0, 0)
killpartsound:Play()
print(killpartsound.IsPlaying) -- It's true but the sound isn't playing
wait(touchedCooldown)
canTouch = true
killpart.BrickColor = BrickColor.new("Dark stone grey")
print(killpartsound.IsPlaying) -- It's returning false now and that means that the sound is done playing but it wasn't even playing
end
end
end)
As you can see I’m getting the sound from SoundService and using the Sound:Play() to play it and I’m also waiting for it to load by using checks to see if it loaded or not and if it hasn’t been loaded yet then wait for it to load then play the sound so what’s the problem here?
If you want to check if the sound that I’m using works in the first place then this is sound link which is made by ROBLOX: Here’s the sound