|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
UncleTaz
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 12795 |
|
| |
|
|
| 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 |
|
|