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

How do I compare three values?

Is there a way to make my script more efficient by comparing the three values more directly or is this the best it can be? Here is my script:

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local fire = workspace.Heat
local warmDist = 24
local hotDist = 12
local burnDist = 4

while true do
	wait(1)
	local distance = (char.HumanoidRootPart.Position - fire.Position).magnitude
	if distance <= warmDist then
		print("It's warm")
	end
	if distance <= hotDist then
		print("It's hot")
	end
	if distance <= burnDist then
		print("It's BURNING HOT")
	end
end

1 answer

✓ Accepted answer

This is a good script but I'd use If-Else loops for the if statements incase for values being unknown or nil or not stated. But it depends on your script.

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