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

Eaten by a black hole... lol?

DELETEDELETE

1 comment

0

The Walkspeed property is in the character's Humanoid.

2 answers

It will make your script a lot more efficient to create a variable instead of using so many lines of code.

 local h = script.Parent
hcount = 60 -- your variable
while wait(1) do -- you can use wait(1) instead of true so you don't have to put wait(1) in your code.
	if hcount == 60 then -- checks to see if hcount is a minute or not
		h.Text = "1:00"
	elseif hcount == 0 then
		h:Remove()
		Endmatch() -- you have to call the function inside of the loop or else the look will keep going
	else
		h.Text = ("0:"..hcount)
		hcount = hcount - 1
	end
end

function Endmatch()
 game.Players:GetPlayers()  
game.Players.WalkSpeed = 5
 end

1 comment

0

Careful. If it is less than ten, it's going to look like, "0:9", "0:8", etc

Issues

A couple of issues I see here:

1.) You are calling a function before it has been declared

2.) You are trying to set the walkspeed of a Service [Players]

3.) Although this isn't an error, it certainly is an issue. You can easily create a loop to get everything shorter!

4.) Don't use :Remove(), Get into a practice of using :Destroy()



function EndMatch()
for _,v in pairs(game.Players:GetPlayers()) do
v.Character["Humanoid"].WalkSpeed = 5
end
end

local h= script.Parent
h.Text = "1:00"
wait(1)
for i = 59,0,-1 do
if i >= 10 then
h.Text = "0:"..i
elseif i < 10 then
h.Text = "0:0"..i
end
wait(1)
end
h:Destroy()

EndMatch()



Links To Help

http://wiki.roblox.com/index.php?title=Loops#For

http://wiki.roblox.com/index.php?title=API:Class/Player

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