#How can i target multiple parts with the same name?

149 messages · Page 1 of 1 (latest)

compact elm
#

if player then
local carParts = {script.Parent.Union, script.Parent.Chassis, script.Parent.Part
}

            for _, carPart in ipairs(carParts) do
                carPart.BrickColor = player.TeamColor
            end
#

It only does one or two parts not all

#

I have like 15 parts

compact elm
#

@lucid snow

#

can you help?

lucid snow
#

i can't

#

cuz i need to sleep

#

it's 2am for me 💀

compact elm
#

my bad

lucid snow
#

wait

#

can u show ur car

#

in explorer

compact elm
#

i mean i just got it from roblox's city template

lucid snow
#

anyways

#

show pls

compact elm
lucid snow
#

no

#

i mean

#

in explorer

#

not toolbox

compact elm
#

thats not what its called tho

#

i renamed it

lucid snow
#

show what inside

#

nvm

#

i will do it myself rq

compact elm
#

oh

lucid snow
#
local inCar = script.Parent:GetChildren()
local plr = game.Players.PlayerAdded:Wait()

for _, v in pairs(inCar) do
    if v.Name == "BackLeftWheel" then return end
    if v.Name == "BackRightWheel" then return end
    if v.Name == "FrontLeftWheel" then return end
    if v.Name == "FrontRightWheel" then return end
    if v.Name == "Light" then return end
    
    if v:IsA("UnionOperation") then
        v.BrickColor = plr.TeamColor
    elseif v:IsA("BasePart") then
        v.BrickColor = plr.TeamColor
    end
end
#

kinda bad but working

compact elm
#

where do i put this

lucid snow
compact elm
#

where

#

where mine was?

lucid snow
lucid snow
lucid snow
compact elm
#

doesnt work : (

lucid snow
#

errors ?

compact elm
#

no

lucid snow
#

u put script inside ur car, right ?

#

can u show me

compact elm
#

I'm on my phone now

#

But

lucid snow
compact elm
#

I put it under the part where it says something like

#

Driversseat.changed

#

If player then

lucid snow
#

??

#

where

compact elm
#

In the car script

#

Ho down a little

lucid snow
#

u mean this ???

compact elm
#

Yea

lucid snow
#

bruuuh

compact elm
#

I put it above car.drivseat

#

Wat

#

Cause It's a red v blue but I want it so u can steal enemies cars

#

Ehwhat did I do wrong?

lucid snow
#

ima send u file

#

txt file

#

open, copy and replace with ur car script

compact elm
#

Ok

#

OK lol

#

Now

#

Do you know how I can make one of these into a tank?

compact elm
#

@lucid snow Tmr can you help me make a tank lol

compact elm
#

Dang it

#

So I'm trying to make another vehicle

#

By ctrl d

#

But now only certain part change

compact elm
#

@lucid snow

#

The script doesnt work

#

it's only reed

#

red

lucid snow
#

?

#

maybe cuz ur player is in red team ?

compact elm
#

no

#

And doyou see the tank car thingy

#

i really gotta make it look better but its not all red

lucid snow
#

uhh

#

i'm soo lazy to help ya

#

i can say what to do

compact elm
#

ok

lucid snow
#

nvm

compact elm
#

wha

#

ok

lucid snow
#

add this after

compact elm
#

after where

plain trailBOT
#

studio** You are now Level 19! **studio

lucid snow
#

this after setcolor function

compact elm
#

i did

#

it was already there

lucid snow
compact elm
#

oh

#

wait

#

yea

#

it still says that

#

still on blue team and still red

#

ok, so the real thing im gona do is add a gui that opens a vechicle thingy and you can spawn it in

#

does that make it any easier

#

@lucid snow

lucid snow
#

sec

#

oh mb

#
player:GetPropertyChangedSignal("Team"):Connect(function()
  setColor(player, car:GetChildren())
end
compact elm
#

well im adding a gui so how can i do it so if u click the button it spawns the car at ur position with ur color?

#

sry

lucid snow
#

yes

compact elm
#

wha

#

yes?

lucid snow
#

yes

compact elm
#

yes

lucid snow
#

yes

compact elm
#

do i do something like ```lua
local RS = game.ReplicatedStorage

script.Parent.TextButton.MouseButton1Click:Connect(function(Player)
local PlrCar = RS.Jeep:Clone()
PlrCar.Parent = game.Workspace
PlrCar:PivotTo(Player.Position)
PlrCar.Color.Value = Player.TeamColor

end)

lucid snow
#

plrCar.Color.Value ?

compact elm
#

i added a stringvalue

#

called color

lucid snow
#

is it server script ?

#
local RS = game.ReplicatedStorage


script.Parent.TextButton.MouseButton1Click:Connect(function(player: Player)
    local PlrCar = RS.Jeep:Clone()
PlrCar.Parent = game.Workspace
PlrCar:PivotTo(Player.Position)
PlrCar.Color.Value = Player.TeamColor
    
end)
compact elm
#

in the car script could i do instead something like ```lua function setColor(plr, inCar)
for _, v in pairs(inCar) do
if v.Name == "BackLeftWheel" then return end
if v.Name == "BackRightWheel" then return end
if v.Name == "FrontLeftWheel" then return end
if v.Name == "FrontRightWheel" then return end
if v.Name == "Light" then return end

    if v:IsA("UnionOperation") then
        v.BrickColor = script.Parent.Color.Value
    elseif v:IsA("BasePart") then
        v.BrickColor = script.Parent.Color.Value

    end
end

end
setColor(player, car:GetChildren())```

#

no

lucid snow
compact elm
#

but its a gui

lucid snow
#

doesn't matter

#

or i'm stupid 🙂

#

idk

compact elm
#

sooo

#

what do i do then

#

how do i specify the local player

lucid snow
#
local RS = game.ReplicatedStorage
local Player = game.Players.PlayerAdded:Wait()

script.Parent.TextButton.MouseButton1Click:Connect(function()
    local PlrCar = RS.Jeep:Clone()
    PlrCar.Parent = game.Workspace
    PlrCar:PivotTo(Player.Position)
    PlrCar.Color.Value = Player.TeamColor    
end)
compact elm
#

im just gonna do it with a gui script

#

as it also works

#

local Player = game.Players.PlayerAdded:Wait(), that doesnt mean its the local player

#

right?

lucid snow
#

???????????

compact elm
#

how can i tell which player clicks the Textbutton

lucid snow
#

it means

lucid snow
compact elm
#

im stupid

compact elm
#

@lucid snow

#

can i have help