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

Fellow robloxian - Need a little help on this one?

Asked by 10 years ago

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?

1 answer

Log in to vote
1
Answered by 10 years ago

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?

0
Cheers man this worked. MrJogimico 25 — 10y
Ad

Answer this question