Pretty much, I'm making a roleplay, and I need audio for certain areas, yeah?
Here's the script:
local ID = 508851549
--script.Parent.Transparency = 1
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local canrend = true
game:GetService("RunService").RenderStepped:connect(function()
local part = char:WaitForChild("HumanoidRootPart")
if (part.Position - script.Parent.Position).magnitude < script.Parent.Size.magnitude/3 and canrend then
canrend = false
local sound = Instance.new("Sound",plr.PlayerGui)
sound.SoundId,sound.Looped = ("rbxassetid://"..ID),true sound:Play()
repeat wait() until(part.Position - script.Parent.Position).magnitude > script.Parent.Size.magnitude/3
canrend = true
sound:Destroy()
end
end)
end)
end)
It works fine in Studio, but when I launch the game and into the player, there is no sound. Any help?

1 comment
Thank you! It works now.