Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

1 by 1 obby minigame, not detecting brick touches?

Asked by 7 years ago

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;

local replicatedStorage = game:GetService('ReplicatedStorage')
local status = replicatedStorage:WaitForChild('InfoValue')

local inGamers = game.Teams.Players:GetPlayers()

local loops = 0

local MG = game.Workspace.Minigame:FindFirstChild("ObbyMinigame")
local teleTo = MG.TeleportToSpawn
local finishPart = MG.CompletePart
local failPart = MG.FailPart

local spawns = game.Workspace.Minigame:FindFirstChild("ObbyMinigame"):FindFirstChild("Spawns"):GetChildren()
local allspawns = math.random(1, #spawns)
local randomspawn = spawns[allspawns]

repeat
    for i, v in pairs(game.Teams.Players:GetPlayers()) do
        v.Character.Torso.CFrame = CFrame.new(teleTo.Position + Vector3.new(0, 2, 0))
        for t = 30, 1, -1 do
            if t == 1 then
                status.Value = v.Name.." has "..t.." second to complete the obby."
            else
                status.Value = v.Name.." has "..t.." seconds to complete the obby."
            end
            if finishPart.Completed.Value == true then
                local completePlayer = game.Players:FindFirstChild(v.Name)
                completePlayer.Score.Value = completePlayer.Score.Value + 1
                t = 1
                finishPart.Completed.Value = false
                break
            elseif failPart.Failed.Value == true then
                for num, failPlayer in pairs(_G.minigame) do
                    if failPlayer == v.Name then
                        table.remove(_G.minigame, num)
                        v.TeamColor = BrickColor.new('Black')
                    end
                end
                t = 1
                failPart.Failed.Value = false
                break
            end
            wait(1)
        end
    end
    loops = loops + 1
until #inGamers <= 1 or loops == 5
script.Disabled = true

In the 'FailPart' and 'CompletePart', I have a BoolValue and a script that does this;

-- In CompletePart
local spawns = game.Workspace.Minigame:FindFirstChild("ObbyMinigame"):FindFirstChild("Spawns"):GetChildren()
local allspawns = math.random(1, #spawns)
local randomspawn = spawns[allspawns]

script.Parent.Touched:connect(function(char)
    script.Parent.Completed.Value = true -- FailPart says 'script.Parent.Failed.Value = true'
    char.Torso.CFrame = CFrame.new(randomspawn.Positon + Vector3.new(0, 5, 0))
end)

No errors in the output.

0
So... what's the problem there? You didn't tell what's going on! The title isn't enough, you gotta be more specific! OfcPedroo 396 — 6y
0
I don't know what you're talking about, but here's something: In your timer, add wait(1) so it actually ticks down per second instead of all at once. DeceptiveCaster 3761 — 6y
0
Script #2 , line #8 --> randomspawn.Positon? Is it supposed to be Position? Also, Script #2, line #6, :connect() is deprecated. Use :Connect() instead. Bilinearly 58 — 5y

Answer this question