So, in my game, I cleaned up my scripts (they were messy) and now, I want to check if the child is touched without the script in the child (over a thousand parts with same name).
What do you want to achieve? I want to control what color the part changes to based on the team the player is on, without the script being in the part.
What is the issue? I can’t find what I should do, or start with.
What solutions have you tried so far? I haven’t tried any because I haven’t found out what to start with,
(mods, change my topic if it is wrong.)
Thank you!
Okay, place a script in Terrainian that says this:
local cubes = script.Parent.Paintableparts:GetChildren()
for i,v in pairs(cubes) do
v.Touched:Connect(function(hit)
--put whatever you need to happen if any of the cubes get touched right here
end)
end
local player = game.Players.LocalPlayer
local playerTeamColor = player.Team.TeamColor
for i, v in pairs(workspace.Terrainian:GetDescendants()) do
if v.Name == "PaintedCube" then
v.Touched:Connect(function(otherPart)
if otherPart.Parent:FindFirstChild("Humanoid") then --checks if player touched
v.BrickColor = playerTeamColor
end
end)
end
end
Local script parented to StarterPlayerScripts folder.