Hey guys! I am making (hate me for this) a glass bridge game and I ran into a problem when playing a “shatter” sound when stepping on the wrong tile. Here is the script:
--//variables
local tiles = game.Workspace.Bridge.Tiles
--//main game
for i, v in pairs(tiles:GetChildren()) do
local tile = v:GetChildren()[math.random(1,2)]
tile.IsReal = false
tile.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local can = true
if can then
can = false
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.Character.Humanoid.Health = 0
tile:WaitForChild("shatter"):Play()
tile.CanCollide = false
tile.Transparency = 1
wait(2)
tile.CanCollide = true
tile.Transparency = 0.45
end
end
end)
end
idc if anyone copies the entire script its just a bridge game
Anyways, the part where it shows tile:WaitForChild("shatter"):Play()
should work, but it doesn’t. The shatter sound is in the tile, and thats all I should know to make it work. Yes this tile is in workspace. The script running this is in ServerScriptService
. I don’t want to move it to StarterPlayer
or StarterGui
because I want other people to hear it as well. I also don’t want the sound parented to the player’s character. Thank you!