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

i need some help with adding a value from a script into my intermission script?

i'm making a sort of castle defend game where i have to use a intermission/round script. but everytime i try to test it. it won't work. please help!

print("Intermission/Rounds are online")
print("If all goes well. These will all run. Right?")
print(":)")

local playercount = script.plrs.Value
local roundtime = 120
local winners = "?"
function onPlayerAdded(player)
     playercount.Value = playercount.Value + 1
end

   if playercount.Value >= 1 then
	script.Parent.Text = "Intermission - 3"
	wait(1)
    script.Parent.Text = "Intermission - 2"
    wait(1)
    script.Parent.Text = "Intermission - 1"
    wait(1.5)
    script.Parent.Text = "Round starting..."
    wait(3)
    script.Parent.Text = "Round time left: roundtime"
    wait(roundtime)
    script.Parent.Text = "GAME OVER!"
    wait(1.5)
    script.Parent.Text = "winners win!"
 end

8 comments

0

is this the full script?

0

yes.

0

Read my bio.

0

hahahahaha

0

not really helping. :I

0

The onPlayerAdded function won't work because it's not connected, should be game.Players.PlayerAdded:connect(function() end)

0

There is a very well put together tutorial on Youtube from Alvinbloxx, its a five part series, it goes over round scripts, I highly recommend it - https://www.youtube.com/watch?v=xgeUbOFQ8sc

0

READ MY DAMN BIO AND INDENT PROPERLY

1 answer

The problem is, you aren't connecting your PlayerAdded function. Whenever you make a function, unless you call it, it won't do anything. In order to call it, you would use this.

game:GetService("Players").PlayerAdded:Connect(onPlayerAdded)

What the above does is it gets the service "Players" from the game and fires whenever a player is added there. It will then fire the "onPlayerAdded" function that you are trying to fire.

Something else I wanna teach you are for loops. The part in your script where you make an individual line for each number you're counting down, you shouldn't be doing that. What you can do it make a "for" loop that will be a variable that starts at 3, ends at 0, and counts down -1 every second. This is what it looks like.

for countdown = 3, 0, -1 do --creates the for loop
	script.Parent.Text = "Intermission - " .. countdown --this is the same as what you had, except since the countdown variable was made in this for loop, you wanna concatenate the variable
	wait(1) --adds a wait one so it doesn't instantly loop through the entire thing
end

Hopefully this helps and if you wanna learn more about these 2 things I will leave a wiki below!

Your entire script with what was showed above:

local playercount = script.plrs.Value
local roundtime = 120
local winners = "?"

function onPlayerAdded(player)
	playercount.Value = playercount.Value + 1
end

game:GetService("Players").PlayerAdded:Connect(onPlayerAdded)

if playercount.Value >= 1 then
	for countdown = 3, 0, -1 do
		script.Parent.Text = "Intermission - " .. countdown
		wait(1)
	end

	wait(1.5)

	script.Parent.Text = "Round starting..."
	wait(3)

	script.Parent.Text = "Round time left: " .. roundtime --also right here, you didn't do like showed in my for loop example above how it's supposed to concatenate the roundtime variable
	wait(roundtime)

	script.Parent.Text = "GAME OVER!"
	wait(1.5)

	script.Parent.Text = "Winners win!"
end

PlayerAdded For Loops

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