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).
function onTouched(hit) local Red = game.Workspace.Game_Files.Round.RedNum local Blue = game.Workspace.Game_Files.Round.BlueNum local Yellow = game.Workspace.Game_Files.Round.YellowNum local Team = hit.Parent.Team.Value if script.Parent.Color == 'Tawny' then Red.Value = Red.Value - 1 game.Workspace.Game_Files.Round. (This is where i want the String value to be used) end end 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
function onTouched(hit) local Red = game.Workspace.Game_Files.Round.RedNum local Blue = game.Workspace.Game_Files.Round.BlueNum local Yellow = game.Workspace.Game_Files.Round.YellowNum local Team = hit.Parent.Team local TeamValue = game.Workspace.Game_Files.Round:FindFirstChild(tostring(Team)).Value local Colour = hit.Parent.Colour if script.Parent.BrickColor == 'Tawny' then Red.Value = Red.Value - 1 TeamValue = TeamValue + 1 script.Parent.Color = Colour.Value end end connection = script.Parent.Touched:connect(onTouched)
Hi Past,
workspace["Part"]; game["Workspace"]["Player1"];
workspace:FindFirstChild("Part"); game:WaitForChild("Workspace"):FindFirstChild("Player1");
function onTouched(hit) local Red = game.Workspace.Game_Files.Round.RedNum local Blue = game.Workspace.Game_Files.Round.BlueNum local Yellow = game.Workspace.Game_Files.Round.YellowNum local Team = hit.Parent.Team.Value if script.Parent.Color == 'Tawny' then Red.Value = Red.Value - 1 game.Workspace.Game_Files.Round:WaitForChild(Team); end end connection = script.Parent.Touched:connect(onTouched)
Thanks,
Best regards,
~~ KingLoneCat