How do I specify a part that has the same name as a bunch of other parts

I need help with making a check point change color when the player touches it but there are many checkpoints and they all have the same name. How do I tell the function to only change the color of the checkpoint that the player touches and not any other one?

1 Like

I would just group every checkpoint in a folder and do this

local checkpointFolder = game.Workspace.checkpointFolder 

for i , v in pairs(checkpointFolder:GetChildren()) do
   v.Touched:Connect(function()
       v.Brickcolor = Enum.Brickcolor.Green -- Idk the syntax of this   
   end)
end

2 Likes

but that affects all the spawn points, I just need one changed in the folder

EDIT: wait… does v.touched just change the part touched in the folder?

Yes it only effects the one that the player touches

1 Like

Its giving me an error

Brickcolor is not a valid member of Part "Workspace.CheckpointsFolder.Checkpoint"  -  Client - Checkpoints:5

How do I change the property of v if v is a part?

Sorry i told you i didn’t know the syntax of Brickcolor but anyways here’s what you should change :

v.BrickColor = BrickColor.new("Lime green")

Did it work ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.