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

My minigame script is breaking?

Asked by 10 years ago

I used this script for my minigames -

AutomaticTimer = false 
CashValue = "Points" 
WinnerCash = 20 
SurvivorCash = 12
FinishCash = 5 
Time = 60 
Intermission = 10 

hint = Instance.new('Hint',Workspace)

while true do
    WinnerName = nil
    value = Intermission
    while value > 0 do
        hint.Text = "Intermission ("..value..")"
        value = value-1
        wait(1)
    end
hint.Text = "A minigame will be selected..."
wait(3)
m = game.Lighting.Minigames:GetChildren()
n = math.random(1,#m)
minigame = m[n]
hint.Text = "The minigame is '"..minigame.Name.."'!"
map = minigame:clone()
map.Parent = Workspace
wait(3)
hint.Text = map.Description.Value
plrs = game.Players:GetChildren()
    for i = 1, #plrs do
        if plrs[i].PlayerGui.PlayGui.Button.Playing.Value == true then
            plrs[i].Character:MoveTo(map.Spawn.Position)
        end
    end
    if map.GameType.Value == "Race" or map.GameType.Value == "Obby" then
        value = 5
        while value > 0 do
            hint.Text = "The round will begin in "..value..""
            value = value-1
            wait(1)
        end
        for i = 0.05, 1, 0.05 do
            map.Wall.Transparency = i
            wait()
        end
        map.Wall.CanCollide = false
        WinnerFinished = false
        map.Finish.Touched:connect(function(hit)
            if hit.Parent:findFirstChild("Humanoid") ~= nil then
                local plr = game.Players:findFirstChild(hit.Parent.Name)
                local cash = plr.leaderstats:findFirstChild(CashValue)
                if not WinnerFinished then
                    cash.Value = cash.Value+WinnerCash
                    WinnerName = plr.Name
                    WinnerFinished = true
                else cash.Value = cash.Value+FinishCash
                end
                hit.Parent:MoveTo(Workspace.GameSpawn.Position)
                local t = hit.Parent:findFirstChild('Survived')
                if t ~= nil then
                    t:remove()
                end
                local h = hit.Parent:findFirstChild('SurvivalCheck')
                if h ~= nil then
                    h:remove()
                end
            end
        end)
    end
    plrs = game.Players:GetChildren()
    for i = 1, #plrs do
        if plrs[i].PlayerGui.PlayGui.Button.Playing.Value == true then
            v = Instance.new('BoolValue')
            v.Parent = plrs[i].Character
            v.Name = "Survived"
            v.Value = true
            s = script.SurvivalCheck:clone()
            s.Parent = plrs[i].Character
            s.Disabled = false
        end
    end
    if map.GameType.Value == "Survival" or map.GameType.Value == "Custom" then
        value = 5
        while value > 0 do
            hint.Text = "The round will begin in "..value..""
            value = value-1
            wait(1)
        end
        plrs = game.Players:GetChildren()
        for i = 1, #plrs do
            map.DisasterScript.Disabled = false
        end
    end
    if not AutomaticTimer then
        Time = minigame.Time.Value
    end 
    value = Time
    while value > 0 do
        hint.Text = "Time left: "..value..""
        value = value-1
        wait(1)
    end
    hint.Text = "Round over!"
    if map.GameType.Value == "Race" or map.GameType.Value == "Obby" then
        if WinnerName ~= nil then
            hint.Text = "The winner was: "..WinnerName.."!"
        else
            hint.Text = "There was no winner this round!"
        end
    elseif map.GameType.Value == "Survival" or map.GameType.Value == "Custom" then
        plrs = game.Players:GetChildren()
        for i = 1, #plrs do
            local s = plrs[i].Character:findFirstChild('SurvivalCheck')
            if s ~= nil then
                s:remove()
            end
            local t = plrs[i].Character:findFirstChild('Survived')
            if t ~= nil then
                if t.Value == true then
                    plrs[i].leaderstats.Points.Value = plrs[i].leaderstats.Points.Value+SurvivorCash
                end
            end
        end
    end
    if map.GameType == "Custom" then
        plrs[i].Character:BreakJoints()
    end
    map:remove()
    wait(1)
    for i = 1, #plrs do
        local t = plrs[i].Character:findFirstChild('Survived')
        if t ~= nil then
            if t.Value == true then
                plrs[i].Character:MoveTo(Workspace.GameSpawn.Position or Workspace.GameSpawn2.Position)
            end
        end
    end
    wait(3)
end

I picked up an error on line 77 about SurvivalCheck. The problem is, whenever it teleports players to the map, the whole script breaks. In output, I get - SurvivalCheck is not a valid member of Script

Here's the SurvivalCheck script -

script.Parent.Humanoid.Died:connect(function()
    script.Parent.Survived.Value = false
end)

Any help?

0
Where is the "SurvivalCheck" script located? Is it a child of the script or a parent? Or is it somewhere else? If it's not located as a child of the script, put it as a child.  lomo0987 250 — 10y
0
Located on line 77, and the script for survial check is below the minigame script. FamousDoge 0 — 10y

1 answer

Log in to vote
0
Answered by
traigla 75
10 years ago

You've written it saying that the SurvivalCheck script is inside that main script. is this true, where is the Survival Check script?

The way you have it set up is that the SurvivalCheck script's parent is the main script.

Ad

Answer this question