Sorry if this is in the wrong place. I have a sound region set up around a box and there’s a spawn point inside that box. A few days ago it was working fine. Now when someone dies inside the box they respawn outside the box? If I delete the sound region block (that is already set to CanCollide false) everything works again (except no music). I didn’t change anything, was there an update that changed CanCollide on transparent blocks?
Thanks in advance!
This is because when roblox characters spawn, they use :MoveTo, which does not directly set the position. The best way to get around this is make the roof higher up and non collidable.
The sound region still acts as a part; Roblox will treat it as such when spawning characters.
When a player spawns, you could always set their position to the spawn directly.
Thank you for replying. So should I just remove the sound region block? I’m not sure how to set the position other than placing a spawn point. I’m researching that right now.
I need more info
Can you send me the place file of what you are refering too? What is this “sound region block” and spawn and how are they located relative to each other.
Are you using sound Objects correctly?
What do you need the “sound region block” for? Is it for playing sounds?
You can play sounds from a local script witthout having to play it through a part by using the following code:
If you play the sound in a local script, only the local player will hear it. If you play it through SoundService, it will play to all players.
local soundObject = --Path to sound object, ideally script.Sound
if not soundObject.IsLoaded then--Wait for sound to load
soundObject.Loaded:wait()
end
soundObject:Play()--Play the sound
Link to Roblox Article about using sounds locally
In Summary
If you need to play a sound that isn’t 2d and is just a sound effect that a player needs to hear, you don’t need to use a part.
This is the inside of the box. While people are here the music changes from the rest of my game. So I made a block that was larger than this block and changed the music using region3
local region = Region3.new(v.Position - (v.Size/2), v.Position +(v.Size/2))
So it only changes the music for the person inside the box.
local SoundRegionsWorkspace = game.ServerStorage:WaitForChild("SoundRegions")
local Found = false
while wait(1) do
for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
Found = false
local region = Region3.new(v.Position - (v.Size/2), v.Position +(v.Size/2))
Put The Parts Into ServerStorage
Could you just parent SoundRegionsWorkspace
to ServerStorage
, and then it won’t be calculated into the physics, and you can still reference it?
Is this correct?
local SoundRegionsWorkspace = game.ServerStorage:WaitForChild("SoundRegions")
Yes, as long as you have a model in game.ServerStorage
called SoundRegions
, you will be able to reference them.
I moved the SoundRegions folder to ServerStorage. Is there anything else in the script I posted earlier that needs to change? Or just that first line? I’m sorry I’m really new to this and learning as I go. I edited it to show the change to the first line. Do I change all of the Workspace references or ServerStorage?
I’m getting an error - Infinite yield possible on ‘ServerStorage:WaitForChild(“SoundRegions”)’
Is that because I placed it in ServerStorage?
Is your script located on the client?
Right now I have it as a local script in StarterGui
You could place the sound regions in the replicated storage / replicated first. Then you can refer to them using game:GetService() on the client.
Clientside scripts cannot access the Server Storage and the Server Script Service.
That did it!!! Thank you. I placed it in ReplicatedStorage, changed the line to show the new location and now its working. I can die and it respawns inside the box.
Thanks for all of your help REALTimothy0812, xBeepBoop, and snorebear!
I thought you were using a server-side script. My bad. For server-side scripts, store items in ServerStorage
. For client-side or things that need to be accessed by both, use ReplicatedStorage
.
As long as the variable can be accessed by a script, it can work.