Temperature Zone System

Hello all! I’m relatively new to scripting and what I am trying to make is a simple temperature system where the player’s temperature may remain constant, gradually increase or decrease based on a zone they are in.

My main issue, however, is that I’m not sure how I would go about achieving this effect. Although I’m sure it’s quite simple to make, I am quite inexperienced and I would prefer that you don’t flat out make the script for me and just advise me as to how I would go about creating such a system.

I’ve been trying at it all morning and I’d really appreciate any kind of help, thank you!

1 Like

i would make a perimeter for each zone that the player could be in (the position of all the 8 corners of the “box”). Then i would check periodically the zone that the player is in. If the player is in a zone that needs to increase it’s temperature, it will do so.

…Something like that

1 Like

How would I go about doing that? Region3 perhaps?

yes, it could be an option, but as far as I know about it, it lags when you use it on big areas.
I have a script where i am doing basically the same and all i do is checking if the player is in between the min and max of the possible x, y, and z values

function ISBetween(minx,miny,minz,maxx,maxy,maxz,pos)
	if pos.X<=maxx and pos.X>=minx and pos.Y<=maxy and pos.Y>=miny and pos.Z<=maxz and pos.Z>=minz then
		return true;
	else
		return false;
	end
end

function IsInArena()
	local HRP = myChar:WaitForChild("HumanoidRootPart")
	return ISBetween(-186,-272,-151,1271,317,417, HRP.Position)
end

an example of usage

3 Likes

Alright, I’ll give it a crack. I’ll keep you posted as to whether it works or not.

An alternative is to use Proximity Prompts to trigger changes between areas.

You could for example place a part with a proximity prompt at the center of the zone and adjust MaxActivationDistance to the size you want the zone to be. This will activate in a circle around the prompt. If you need the zone to be different than a circle then this is not the best solution.

You can then also change prompt Style from Default to Custom so the proximity prompt is always invisible and only works as a trigger.

You can then use the built in functions PromptShown and PromptHidden to trigger temperature changes when the player enter and leave a zone.

I think I can help a little bit more:

So lets assume we are in an arctic environment

lets say a fireplace is the only way to increase your temperature, this would be a temperature increase zone

if completely outside, this would be a general decrease temperature zone (ignoring clothing)

if inside a building, this would still decrease temperature, but not as harshly perhaps and remain constant?

For fireplace I would make a zone using zoneplusv3 module and if player enters the zone, start heating them up

for Inside detection, I would also use zone module to detect is player enters/exits a building to determine temperature increment.

For outside detection, perhaps check using raycasts, that or rely heavily on the zoneplusv3 module’s PlayerExitted events, if player exits from a determined building then they are outside.

Module:

Thanks all. This is all really good advice. Though I think I’ll wait until I improve my scripting ability by a decent amount - this is all beginning to become a tad bit too complicated for someone of my skill level!