Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I check whether a player built room is sealed?

Hello everyone, I have once again come with a question.

For my current project, I would like to include oxygenated rooms. After thinking for a while and looking online I have not been able to find a way to check whether a room is sealed or not in Roblox. I had the idea to do something with raycasts but of course, that would be a big performance hit. I have therefore come here to ask you guys for advice!

In my project, players are able to build constructs with blocks of any size. The problem is here that I have no idea how to check if such a room is sealed or not. Once it's sealed, of course, oxygen can flow and players can take off spacesuits and breathe freely. A room can be any size and any shape and built by any shape or size blocks.

If anyone knows an existing solution to my problem or a suggestion on how to approach this problem, I would highly appreciate it!

1 comment

0

Im sorry but this is not a request site. Please read this https://scriptinghelpers.org/help/community-guidelines for more imformation about ScriptingHelpers

1 answer

This may not work, but i have an idea. Have little "oxygen" parts moving around. And as long as they are in a certain area, it is okay. You can use the 4 corners of the baseplate of the room for that area. Now they will move around. If they bang into wall, they reset and take off in another random direction. If they escape the area, it means the room is not sealed, and then a bool value becomes false. You can make the player take constant damage when that happens or whatever. It is a good idea. The "oxygen" can move really fast so the server will know really fast if the room is sealed or not. You can still make it any size. The player will just have to upgrade his area that he can build in or how big that room is. This is the best idea I can come up with.
In the oxygen, you will need a boolvalue and 2 scripts. Inside the room, there needs to be another bool. In all parts the player places there needs to be something called "ActiveWall". Script1:

local pos = script.Parent.Position
script.Parent.Rotation = Vector3.new(math.random(-179,180),math.random(-179,180)math.random(-179,180))
while true do
	if script.Parent.Position.X > 5 or script.Parent.Position.X < -5 or script.Parent.Position.Y > 8 or script.Parent.Position.Y < -8 then
	workspace.ThisRoom.SealedValue = false
end
	if script.Parent.HitWall.Value == true then  
	script.Parent.Position = pos
	script.Parent.Rotation = Vector3.new(math.random(-179,180),math.random(-179,180)math.random(-179,180))
	end
	script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,3)
wait(0.05)
end

Script2:

funcion onTouched(part)
	if part.Parent.ActiveWall then
		script.Parent.HitWall.Value == true
	wait(0.15)
	end

I hope this helps.

3 comments

0

This is not a bad idea, I'll have a look if I can work something out of this. Maybe something with a flood fill?

0

Wouldn't lag be a potential issue here? You'd have to run physics simulation for every room's simulated oxygen parts on the server.

0

Somewhat, however the script does not need to run when the room is not changing shape

This discussion is preserved as it was. New answers, comments, and votes are closed.