How do i choose a part based on a String Value?
Asked by
6 years ago Edited 6 years ago
So basically when a player touches a block it removes a point from brick colours team and gives a point to the person who touched its team, I have a StringValue with the Value as the Team Name meaning i can get the players team from that String value but how would i use that Value to select a thing (An int value in this instance).
01 | function onTouched(hit) |
03 | local Red = game.Workspace.Game_Files.Round.RedNum |
04 | local Blue = game.Workspace.Game_Files.Round.BlueNum |
05 | local Yellow = game.Workspace.Game_Files.Round.YellowNum |
06 | local Team = hit.Parent.Team.Value |
08 | if script.Parent.Color = = 'Tawny' then |
09 | Red.Value = Red.Value - 1 |
10 | game.Workspace.Game_Files.Round. (This is where i want the String value to be used) |
14 | connection = script.Parent.Touched:connect(onTouched) |
I've tried this but this also doesn't work, giving this error:
Workspace.Floor_Tiles.Column_1.Floor_Tile.Colouring:7: attempt to index a nil value
01 | function onTouched(hit) |
03 | local Red = game.Workspace.Game_Files.Round.RedNum |
04 | local Blue = game.Workspace.Game_Files.Round.BlueNum |
05 | local Yellow = game.Workspace.Game_Files.Round.YellowNum |
06 | local Team = hit.Parent.Team |
07 | local TeamValue = game.Workspace.Game_Files.Round:FindFirstChild( tostring (Team)).Value |
08 | local Colour = hit.Parent.Colour |
10 | if script.Parent.BrickColor = = 'Tawny' then |
11 | Red.Value = Red.Value - 1 |
12 | TeamValue = TeamValue + 1 |
13 | script.Parent.Color = Colour.Value |
18 | connection = script.Parent.Touched:connect(onTouched) |