So, i made a localscript that plays a sound after touching a part, but it plays the sound for everyone, and i made a local script just because i wanted it to do that. Here's the script:
01 | local part = game.Workspace.elevatorsong |
02 | part.Touched:Connect( function (hit) |
03 | if not hit.Parent:FindFirstChild( "Humanoid" ) then return end |
04 | spawn( function () |
05 | wait( 0 ) |
06 | game.Workspace.elevatorsong.CanTouch = false |
07 | game.Workspace.elevsongg.elevsong:Play() |
08 | wait( 31.88 ) |
09 | game.Workspace.elevatorsong.CanTouch = true |
10 | end ) |
11 | end ) |
Ok LAST post because I know this works. I know this works because I tested it with my brother in the game.
The local script should be in StarterPlayerScripts. The sound should be in PlayerGui. And the part should be in workspace.
01 | local part = game.Workspace.elevatorsongpart |
02 | local song = game.Players.LocalPlayer:WaitForChild( "PlayerGui" ):WaitForChild( "elevatorsong" ) |
03 | local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() |
04 | part.Touched:Connect( function (hit) |
05 | if not hit.Parent:FindFirstChild( "Humanoid" ) then return end |
06 | if hit.Parent = = character then |
07 | spawn( function () |
08 | wait( 0 ) |
09 | part.CanTouch = false |
10 | song:Play() |
11 | song.Stopped:Wait() |
12 | part.CanTouch = true |
13 | end ) |
14 | end |
15 | end ) |
01 | local part = game.Workspace.elevatorsongpart |
02 | local song = game.Players.LocalPlayer:WaitForChild( "PlayerGui" ):WaitForChild( "elevsongg" ):WaitForChild( "elevatorsong" ) |
03 | part.Touched:Connect( function (hit) |
04 | if not hit.Parent:FindFirstChild( "Humanoid" ) then return end |
05 | spawn( function () |
06 | wait( 0 ) |
07 | part.CanTouch = false |
08 | song:Play() |
09 | song.Stopped:Wait() |
10 | part.CanTouch = true |
11 | end ) |
12 | end ) |
also changed some names so that it's less confusing, also, the song is inside of a model, that's why there's elevsongg and elevatorsong, but the model only has the sound in it so it's okay.