Advertisement
Guest User

Untitled

a guest
May 24th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. -- Jonathan Patrick | Entelicon | 1/5/2019
  2.  
  3. local MatchModule = require(game.ReplicatedStorage.Modules.MatchModule);
  4. local RoundModule = require(game.ReplicatedStorage.Modules.RoundModule);
  5.  
  6. local localPlayer = nil;
  7.  
  8. local setStateBindableEvent = nil;
  9. local shopEnteredBindableEvent = nil;
  10. local shopExitedBindableEvent = nil;
  11. local matchInformationDisplayedBindableEvent = nil;
  12.  
  13. local playerJoinedMatchClientRemoteEvent = nil;
  14.  
  15. local hasMatchInformationBeenDisplayed = false;
  16.  
  17. function Initialize()
  18.  
  19. localPlayer = game.Players.LocalPlayer;
  20.  
  21. setStateBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.SetStateBindableEvent;
  22. shopEnteredBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopEnteredBindableEvent;
  23. shopExitedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopExitedBindableEvent;
  24. matchInformationDisplayedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.Interface.MatchInformationDisplayedBindableEvent;
  25.  
  26. playerJoinedMatchClientRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.PlayerJoinedMatchClientRemoteEvent;
  27.  
  28. end
  29.  
  30. function OnShopEntered(shopName)
  31. SetWalkspeed(0);
  32. end
  33.  
  34. function OnShopExited(shopName)
  35. setStateBindableEvent:Fire();
  36. end
  37.  
  38. function OnMatchInformationDisplayed()
  39. wait(0.1);
  40. setStateBindableEvent:Fire();
  41. end
  42.  
  43. function OnPlayerJoinedMatch(playerName)
  44.  
  45. if (playerName == localPlayer.Name) then
  46.  
  47. local isMatchOpenOrLiveBool = MatchModule.IsMatchOpen() == true or MatchModule.IsMatchLive() == true;
  48. local isMatchOpenBool = MatchModule.IsMatchOpen() == true and MatchModule.IsMatchLive() == false;
  49. local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
  50. local allowMovementBool = (isMatchOpenOrLiveBool == true) and (isMatchOpenBool == false) and (isEntrantValue == true) and hasMatchInformationBeenDisplayed;
  51.  
  52. wait(0.1);
  53.  
  54. if (allowMovementBool) then
  55. setStateBindableEvent:Fire()
  56. else
  57. SetWalkspeed(0);
  58. end
  59. end
  60. end
  61.  
  62. function OnMatchInformationDisplayed()
  63. hasMatchInformationBeenDisplayed = true;
  64. OnPlayerJoinedMatch(localPlayer.Name);
  65. end
  66.  
  67. function SetWalkspeed(walkspeedValue)
  68. localPlayer.Character:WaitForChild("Humanoid").WalkSpeed = walkspeedValue;
  69. end
  70.  
  71. function OnRoundStateUpdated(updatedRoundState)
  72.  
  73. local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
  74.  
  75. if (isEntrantValue == true) then
  76.  
  77. local isMatchFininished = updatedRoundState == "MatchFinished";
  78.  
  79. if (isMatchFininished) then
  80. hasMatchInformationBeenDisplayed = false;
  81. wait(0.1);
  82. SetWalkspeed(0);
  83. else
  84. setStateBindableEvent:Fire();
  85. end
  86. end
  87. end
  88.  
  89. Initialize();
  90.  
  91. OnPlayerJoinedMatch(localPlayer.Name);
  92.  
  93. shopEnteredBindableEvent.Event:Connect(OnShopEntered);
  94. shopExitedBindableEvent.Event:Connect(OnShopExited);
  95.  
  96. matchInformationDisplayedBindableEvent.Event:Connect(OnMatchInformationDisplayed);
  97.  
  98. RoundModule.OnRoundStateUpdated():Connect(OnRoundStateUpdated);
  99.  
  100. playerJoinedMatchClientRemoteEvent.OnClientEvent:Connect(OnPlayerJoinedMatch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement