generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: GUI Countdown?

Previous Thread :: Next Thread 
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
21 Jul 2014 01:13 PM
Hello, I have FilteringEnabled ticked in Workspace and it's the first time I've used a RemoteEvent to do a countdown.

I want to do know if there is a more efficient way for this to work, I have like 5 RemoteEvents in ReplicatingStorage and was wondering if I was only suppose to use 1 and just change the data or something xD

Anyway:

5 RemoteEvents in ReplicatingStorage called "3, 2, 1 , Go, donecountdown"

Serverscript:

local RemoteEventthree = game.ReplicatedStorage.three
local RemoteEventtwo = game.ReplicatedStorage.two
local RemoteEventone = game.ReplicatedStorage.one
local RemoteEventGo = game.ReplicatedStorage.Go
local RemoteEventdonecountdown = game.ReplicatedStorage.donecountdown

RemoteEventthree:FireAllClients(three)
wait(1)
RemoteEventtwo:FireAllClients(two)
wait(1)
RemoteEventone:FireAllClients(one)
wait(1)
RemoteEventGo:FireAllClients(Go)
--code
wait(1)
RemoteEventdonecountdown:FireAllClients(donecountdown)

LocalScript:

local Eventthree = game.ReplicatedStorage.three
local Eventtwo = game.ReplicatedStorage.two
local Eventone = game.ReplicatedStorage.one
local EventGo = game.ReplicatedStorage.Go
local Eventdonecountdown = game.ReplicatedStorage.donecountdown



Eventthree.OnClientEvent:connect(function(three)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Text = 3
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Visible = true
end)

Eventtwo.OnClientEvent:connect(function(two)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Text = 2
end)

Eventone.OnClientEvent:connect(function(one)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Text = 1
end)

EventGo.OnClientEvent:connect(function(Go)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Text = "Go!"
end)

Eventdonecountdown.OnClientEvent:connect(function(donecountdown)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Visible = false
end)
Report Abuse
UncleTaz is not online. UncleTaz
Joined: 19 Aug 2009
Total Posts: 12795
21 Jul 2014 01:16 PM
With countdowns, I do suggest using remote events.

Although I suggest you tinker around with it a bit more. They can be really useful. And instead of just writing the code over and over just use a for loop

for 1 = 3, 0, -1 do
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Text = i
if i == 0 then
game.Players.LocalPlayer.PLayerGui.ScreenGui.Frame.Countdown.Text = "Go!"
end
--code
end
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
21 Jul 2014 01:19 PM
Oh yeah, loops. I only used one RemoteFunction before and I had a wait(1) in there but for some reason the wait didn't work? I'll try again, thanks :)
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
21 Jul 2014 01:35 PM
Okay how about now?

2 RemoteEvents in ReplicatedStorage called ("Countdown, doneCountdown")

ServerScript:

local RemoteEvent = game.ReplicatedStorage.Countdown
local RemoteEvent2 = game.ReplicatedStorage.doneCountdown

RemoteEvent:FireAllClients(Countdown)
wait(3)
--code
wait(1)
RemoteEvent2:FireAllClients(doneCountdown)

LocalScript:

local Event = game.ReplicatedStorage.Countdown
local Event2 = game.ReplicatedStorage.doneCountdown

Event.OnClientEvent:connect(function(Countdown)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Visible = true
for i = 3, 1, -1 do
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Text = i
wait(1)
end
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Text = "Go!"
end)

Event2.OnClientEvent:connect(function(doneCountdown)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Countdown.Visible = false
end)

It works but is that the most efficient I can get it do you think?
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
21 Jul 2014 02:10 PM
bump
Report Abuse
UncleTaz is not online. UncleTaz
Joined: 19 Aug 2009
Total Posts: 12795
21 Jul 2014 02:12 PM
This is good!
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
21 Jul 2014 02:18 PM
:D

Thanks for the loop reminder, now it's much more efficient than having like 5 RemoteFunctions xD
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image