I am trying to make a temperature system within a local script that is dependent on players' distance from heat sources. How can I make it so my script may recognize multiple heat sources and treat each as independent emissions of heat? Here has been my attempt; the loop can't recognize my multiple instances of "fire" and I don't know how to fix it.
local Players = game:GetService("Players")
local player = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):wait()
local char = player.Character or player.CharacterAdded:Wait()
local heat = game.Workspace.Heat:GetChildren("Fire")
local heatDist = 8
local temp = game.ReplicatedStorage:WaitForChild(player.Name):WaitForChild("Temp")
while true do
wait(1)
local distance = (char.HumanoidRootPart.Position - heat.Position).magnitude
if distance <= heatDist then
temp.Value = temp.Value+1
end
end

1 comment
Will do! Thank you!