1 by 1 obby minigame, not detecting brick touches?
In my game, I have a minigame where each player takes in turns to complete the obby.
If the player falls (or fails), it will touch and invisible brick on the floor, stop their turn, teleport them to the waiting podium, take their name out of a global table and change their team to an other team.
If a player completes it, the player will stay on the team and in the table, their score will be increased by 1 and their turn will end.
This is the script;
01 | local replicatedStorage = game:GetService( 'ReplicatedStorage' ) |
02 | local status = replicatedStorage:WaitForChild( 'InfoValue' ) |
04 | local inGamers = game.Teams.Players:GetPlayers() |
08 | local MG = game.Workspace.Minigame:FindFirstChild( "ObbyMinigame" ) |
09 | local teleTo = MG.TeleportToSpawn |
10 | local finishPart = MG.CompletePart |
11 | local failPart = MG.FailPart |
13 | local spawns = game.Workspace.Minigame:FindFirstChild( "ObbyMinigame" ):FindFirstChild( "Spawns" ):GetChildren() |
14 | local allspawns = math.random( 1 , #spawns) |
15 | local randomspawn = spawns [ allspawns ] |
18 | for i, v in pairs (game.Teams.Players:GetPlayers()) do |
19 | v.Character.Torso.CFrame = CFrame.new(teleTo.Position + Vector 3. new( 0 , 2 , 0 )) |
22 | status.Value = v.Name.. " has " ..t.. " second to complete the obby." |
24 | status.Value = v.Name.. " has " ..t.. " seconds to complete the obby." |
26 | if finishPart.Completed.Value = = true then |
27 | local completePlayer = game.Players:FindFirstChild(v.Name) |
28 | completePlayer.Score.Value = completePlayer.Score.Value + 1 |
30 | finishPart.Completed.Value = false |
32 | elseif failPart.Failed.Value = = true then |
33 | for num, failPlayer in pairs (_G.minigame) do |
34 | if failPlayer = = v.Name then |
35 | table.remove(_G.minigame, num) |
36 | v.TeamColor = BrickColor.new( 'Black' ) |
40 | failPart.Failed.Value = false |
47 | until #inGamers < = 1 or loops = = 5 |
In the 'FailPart' and 'CompletePart', I have a BoolValue and a script that does this;
2 | local spawns = game.Workspace.Minigame:FindFirstChild( "ObbyMinigame" ):FindFirstChild( "Spawns" ):GetChildren() |
3 | local allspawns = math.random( 1 , #spawns) |
4 | local randomspawn = spawns [ allspawns ] |
6 | script.Parent.Touched:connect( function (char) |
7 | script.Parent.Completed.Value = true |
8 | char.Torso.CFrame = CFrame.new(randomspawn.Positon + Vector 3. new( 0 , 5 , 0 )) |
No errors in the output.