I am making a Horror game at the moment, and early on in the game a player walks through a block which they cannot see. On walking through that block, the game is meant to play a sound. But it's not. What I did was created a block and turned off Can Collide and anchored it. I added the following script as a child to the part:
local SoundID = 143709330 local Block = script.Parent local Debounce = false Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=143709330" .. SoundID) wait(1/30) Block.Touched:connect(function(Hit) if Debounce == false then Debounce = true local Hum = Hit.Parent:findFirstChild("Humanoid") if Hum then local Sound = Instance.new("Sound", Workspace) Sound.Volume = 1 Sound.SoundId = "http://www.roblox.com/asset/?id=143709330" .. SoundID Sound.Looped = false Sound.Pitch = 1 Sound.Archivable = false Sound:Play() end end end)
My thoughts are that I completely messed this up. anyone help?
Well, for starters you put the ID in twice:
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=143709330" .. SoundID) --should be Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. SoundID)
You also did the same thing here:
Sound.SoundId = "http://www.roblox.com/asset/?id=143709330" .. SoundID --should be Sound.SoundId = "http://www.roblox.com/asset/?id=" .. SoundID
And lastly, you forgot to set the debounce back to false, unless you didn't want that to happen?