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

how to fix the sound play on the all players?

Asked by 3 years ago
Edited 3 years ago

Hello! I have 2 almost identical scripts, but one of them work incorrectly. The meaning of scripts: when you step on a part, the local player plays a sound. Problem: the first script works correctly, but the second does not, he just plays for all the players

Script:

1-st

local function BlackScreen(otherPart)
    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
    if player then
        player.Character.Humanoid.WalkSpeed = 0
        player.Character.Humanoid.JumpPower = 0
        player.PlayerGui.ScreenGui.Black.BackgroundTransparency = 0
        game.SoundService.Sound:Stop()
        game.SoundService.Sound1:Play()
        wait(2.6)
        game.SoundService.Sound2:Play()
        wait(1)
        game.SoundService.Sound:Play()
        player.PlayerGui.ScreenGui.Black.BackgroundTransparency = 1
        player.Character.Humanoid.WalkSpeed = 16
        player.Character.Humanoid.JumpPower = 50
    end
end

2-nd

local function BlackScreen2(otherPart)
    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
    if player then
        game.SoundService.Sound:Stop()
        wait(6)
        game.SoundService.Sound3:Play() 
        wait(3.720)
        game.SoundService.Sound:Play()
    end
end

1 answer

Log in to vote
1
Answered by 3 years ago

Okay, I fixed it. I just added these lines to the second code:

        player.Character.Humanoid.WalkSpeed = 16
        player.Character.Humanoid.JumpPower = 50
        player.PlayerGui.ScreenGui.Black.BackgroundTransparency = 1

I didn't understand what the bug was, but I hope it helps someone :/

0
ty Ali_MTR 30 — 3y
Ad

Answer this question