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

Sound in player GUI wont play?

Asked by 6 years ago
Edited 6 years ago

A sound isn't playing when I step on the block meant to trigger it. There aren't any output errors, and experimental mode is on so filtering enabled shouldn't be a problem. Here's the code. EDIT: It works in studio just not online

local part = script.Parent
local players = game:GetService("Players")
local played = false

part.Touched:connect(function(hit)
    local char = hit.Parent 
    if char.Humanoid and played == false then
        local plr = players:WaitForChild(char.Name)
        plr.PlayerGui.Sounds.windows:Play()
            played = true
            wait(5)
        end
end) 
0
is it in a localscript? wookey12 174 — 6y
0
No its just in a Script ninjayoshi800 5 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

First make a sound in the Workspace, Next change the sound properties to your desire. Paste this code in the same script: And then change "SOUND" to the name of the object.

local part = script.Parent local players = game:GetService("Players") local played = false

part.Touched:connect(function(hit) local char = hit.Parent if char.Humanoid and played == false then local plr = players:WaitForChild(char.Name) game.Workspace.SOUND:Play() played = true wait(5) end end) -- If This Is Used In A Free Model | CREDIT ME! -- It Is Rude To Delete This Line -- -- Made By minecraftisawsome17 --

Ad

Answer this question