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

How can I make my script recognize multiple parts with the same name?

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 answer

✓ Accepted answer

Change the name of them instead, and label them differently, this is the easiest or simplest method you could use.

1 comment

0

Will do! Thank you!

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