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

Why doesn't this script work?

Asked by 8 years ago

Here's the script that is supposed to run first. This one works perfectly fine:

repeat wait() until game.Players.NumPlayers > 0

player = nil
for _, v in pairs(game.Players:GetChildren()) do
        player = v
end

function onTouched(hit)
        hit:Destroy()
        game.Workspace.Winner.Disabled = false
        player.PlayerGui.ScreenGui.YouBeatTheLevel.Visible = true
        wait(2.5)
        script.Parent.Parent.Parent:Destroy()
        wait(2.5)
        player.PlayerGui.ScreenGui.YouBeatTheLevel.Visible = false
        local cloneNextMap = game.ServerStorage.Maps["2"]:clone()
        cloneNextMap.Parent = game.Workspace
end

script.Parent.Touched:connect(onTouched)

And then heres the other one that's supposed to run after the other one, this one doesn't work:

wait(5)
        player = nil
    for _, v in pairs(game.Players:GetChildren()) do
        player = v
    end

if game.Workspace.PlayerAttempts == 1 then
    player.PlayerGui.Attempts.NumberOfAttempts.Visible = true
    wait(3)
    player.PlayerGui.Attempts.NumberOfAttempts.Visible = false
    player.PlayerGui.Attempts.OneAttempt.Visible = true
    wait(2)
    player.PlayerGui.Attempts.OneAttempt.Visible = false
end

game.Workspace.PlayerAttempts.Value = 0
script.Disabled = true
1
Is PlayerAttempts an IntValue? Discern 1007 — 8y
0
It's a number value in Workspace. SchonATL 15 — 8y

1 answer

Log in to vote
2
Answered by
Discern 1007 Moderation Voter
8 years ago
wait(5)
        player = nil
    for _, v in pairs(game.Players:GetChildren()) do
        player = v
    end

if game.Workspace.PlayerAttempts.Value == 1 then --A value is stored in an instance's property "Value", which you need to specify. Adding ".Value" will fix it! ^_^
    player.PlayerGui.Attempts.NumberOfAttempts.Visible = true
    wait(3)
    player.PlayerGui.Attempts.NumberOfAttempts.Visible = false
    player.PlayerGui.Attempts.OneAttempt.Visible = true
    wait(2)
    player.PlayerGui.Attempts.OneAttempt.Visible = false
end

game.Workspace.PlayerAttempts.Value = 0
script.Disabled = true

If I helped you, be sure to accept my answer! :D

0
Thank you so much! I totally missed that. SchonATL 15 — 8y
0
Explain your answer... unmiss 337 — 8y
0
Comment Discern 1007 — 8y
0
JackCTaylor, I understand it. It's just that it slipped my mind because I was typing so fast. SchonATL 15 — 8y
0
See the comment I placed in the script? Discern 1007 — 8y
Ad

Answer this question