Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't this script work?

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

2 comments

1

Is PlayerAttempts an IntValue?

0

It's a number value in Workspace.

1 answer

✓ Accepted answer
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

5 comments

0

Thank you so much! I totally missed that.

0

Explain your answer...

0

Comment

0

JackCTaylor, I understand it. It's just that it slipped my mind because I was typing so fast.

0

See the comment I placed in the script?

This discussion is preserved as it was. New answers, comments, and votes are closed.