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 » Scripters
Home Search
 

Is there any better way to do this?

Previous Thread :: Next Thread 
MDClockwork is not online. MDClockwork
Joined: 08 Mar 2015
Total Posts: 1400
14 Apr 2016 02:35 PM
events.Jail.OnServerEvent:connect(function(plr, timer)
wait(1)
local running = true
while running do
wait(1)
if plr and plr.TeamColor == game.Teams.Prisoner.TeamColor and timer.Value ~= 0 then
timer.Value = timer.Value - 1
print(timer.Value)
elseif plr and plr.TeamColor == game.Teams.Prisoner.TeamColor and timer.Value == 0 then
plr.TeamColor = game.Teams.German.TeamColor
wait()
plr:LoadCharacter()
running = false
elseif (plr.TeamColor ~= game.Teams.Prisoner.TeamColor and timer.Value == 0) or timer.Value == 0 then
running = false
end
end
end)


I need a way to count down a timer whenever someone initially gets put on a team. Currently, if you get put on the team in a few times in a short period of time, or even respawned (I know why it does that), the timer will go down twice as fast as before.

Help?

Report Abuse
MDClockwork is not online. MDClockwork
Joined: 08 Mar 2015
Total Posts: 1400
14 Apr 2016 03:22 PM
Bump

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:24 PM
What exactly are you trying to do?


Report Abuse
MDClockwork is not online. MDClockwork
Joined: 08 Mar 2015
Total Posts: 1400
14 Apr 2016 03:26 PM
When a player gets put on a team, a timer value in leaderstats (it's defined by "timer" at the top, it was passed over by the client to the server)

counts down until it hits 0, then switches a player back to the default team, and respawns them.

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:33 PM
well based on what you just said i just made a little thing. is this what you want?

switchPlayer = function(plr,time)
local prevcolor = plr.TeamColor
plr.TeamColor = BrickColor.new("Bright red")
for i = time,0,-1 do
wait(1)
end
plr.TeamColor = prevcolor
plr:LoadCharacter()
end

switchPlayer(game.Players.Player1,60)


Report Abuse
MDClockwork is not online. MDClockwork
Joined: 08 Mar 2015
Total Posts: 1400
14 Apr 2016 03:36 PM
What is this?

switchPlayer(game.Players.Player1,60)

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:40 PM
well i made a function that after the player changes teams, a timer counts down then changes the player back to the default team and then resets the player


Report Abuse
MDClockwork is not online. MDClockwork
Joined: 08 Mar 2015
Total Posts: 1400
14 Apr 2016 03:42 PM
The problem is, the event is firing several times and continuing even after the player switched teams to default (and when they get switched back, the timer goes down twice as fast)

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:47 PM
okay so is this what you want?

player changes team
timer counts down
timer hits 0
player changes back to default team
player resets

?


Report Abuse
MDClockwork is not online. MDClockwork
Joined: 08 Mar 2015
Total Posts: 1400
14 Apr 2016 03:50 PM
pretty much except the timer is re-firing over the other one and it's counting down twice as fast...

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:58 PM
just use a debounce and dont let the player fire the event until the timer is over. What im wondering is what exactly are you trying to do with your game. Can you explain how it works? What do the germans and prisoners do?


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:59 PM
i just reformatted your code

local running = false

events.Jail.OnServerEvent:connect(function(plr, timer)
if not running then
running = true
while wait(1) and running do
if timer.Value ~= 0 then
if plr.TeamColor == game.Teams.Prisoner.TeamColor then
timer.Value = timer.Value - 1
end
else
if plr.TeamColor == game.Teams.Prisoner.TeamColor then
plr:LoadCharacter()
running = false
else
running = false
end
end
end
running = false
end
end)


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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