So my aim is to make a zone-capture thing: I want to detect a player, get his/her team, then change the colour of the zone to the team colour.
I have this:
local regionPart = game.Workspace.BoundaryZone local pos1, pos2 = (regionPart.position - (regionPart.Size/2)), (regionPart.position + (regionPart.Size/2)) local region = Region3.new(pos1, pos2) while true do wait(1) local partsInRegion = workspace:FindPartsInRegion3(region, game.Workspace.Baseplate,1000) local playersFound = {} for i, v in pairs (partsInRegion) do if v.Parent:FindFirstChild("Humanoid") ~= nil then print("Player found in region!", v.Parent.Name) playersFound[v.Parent.Name] = v.Parent table.insert(playersFound, v.Parent) end end for i, vin pairs (playersFound) do spawn(function() --[[if v.TeamColor == game.Teams.Peace.TeamColor then wait(2) zone.BrickColor = v.TeamColor ]]-- end end) end end
The script I have detects the parts that make up the player's character, but as I said I want the overall player so I can change his/her team. I'm guessing I need to use "GetPlayerFromCharacter" but idk where to slip it in?
Many thanks for reading
i use a localscript, i think it works with a normal script as long as you remove the "and v.Parent.Name ==localplayer.Name"
for i,v in pairs(workspace:FindPartsInRegion3(region,nil,100)) do if v.Name == "HumanoidRootPart" and v.Parent.Name==localplayer.Name then wait(); print(v.Parent.Name) end end