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

How would I change a brick color for one person?

So I'm helping a friend and I'm not entirely sure how to change a brick color for just one person. Here is his code:

function onTouched(abc,hit) 

    if hit.Parent:FindFirstChildOfClass("Humanoid") then 

        wait(1)
        abc.BrickColor = BrickColor.Green()

    end 

end 

for i,v in pairs(script.Parent:GetChildren()) do 

    if v.Name == "check" then 

        v.Touched:Connect(function(hit) 

             onTouched(v,hit) 

        end) 

    end 

end

If you could point us in the right direction or help us out that would be awesome :)

1 answer

So OnTouched only uses one parameter.And that parameter is the thing that touched it.

So here if your hand touched the brick the hit will be the hand and it parent of hit will the the player character model.

Note code is tested in studio and works.

function onTouched(hit) 

    if hit.Parent:FindFirstChildOfClass("Humanoid") then 
        wait(1)
        hit.BrickColor = BrickColor.Green()

    end 

end 

for i,v in pairs(script.Parent:GetChildren()) do 

    if v.Name == "check" then 

        v.Touched:Connect(function(hit) 

             onTouched(hit) 

        end) 

    end 

end

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