Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Jonathan Patrick | Entelicon | 1/5/2019
- local MatchModule = require(game.ReplicatedStorage.Modules.MatchModule);
- local RoundModule = require(game.ReplicatedStorage.Modules.RoundModule);
- local localPlayer = nil;
- local setStateBindableEvent = nil;
- local shopEnteredBindableEvent = nil;
- local shopExitedBindableEvent = nil;
- local matchInformationDisplayedBindableEvent = nil;
- local playerJoinedMatchClientRemoteEvent = nil;
- local hasMatchInformationBeenDisplayed = false;
- function Initialize()
- localPlayer = game.Players.LocalPlayer;
- setStateBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.SetStateBindableEvent;
- shopEnteredBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopEnteredBindableEvent;
- shopExitedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.ShopExitedBindableEvent;
- matchInformationDisplayedBindableEvent = game.ReplicatedStorage.Messages.Bindable.Events.Client.Interface.MatchInformationDisplayedBindableEvent;
- playerJoinedMatchClientRemoteEvent = game.ReplicatedStorage.Messages.Remote.Events.PlayerJoinedMatchClientRemoteEvent;
- end
- function OnShopEntered(shopName)
- SetWalkspeed(0);
- end
- function OnShopExited(shopName)
- setStateBindableEvent:Fire();
- end
- function OnMatchInformationDisplayed()
- wait(0.1);
- setStateBindableEvent:Fire();
- end
- function OnPlayerJoinedMatch(playerName)
- if (playerName == localPlayer.Name) then
- local isMatchOpenOrLiveBool = MatchModule.IsMatchOpen() == true or MatchModule.IsMatchLive() == true;
- local isMatchOpenBool = MatchModule.IsMatchOpen() == true and MatchModule.IsMatchLive() == false;
- local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
- local allowMovementBool = (isMatchOpenOrLiveBool == true) and (isMatchOpenBool == false) and (isEntrantValue == true) and hasMatchInformationBeenDisplayed;
- wait(0.1);
- if (allowMovementBool) then
- setStateBindableEvent:Fire()
- else
- SetWalkspeed(0);
- end
- end
- end
- function OnMatchInformationDisplayed()
- hasMatchInformationBeenDisplayed = true;
- OnPlayerJoinedMatch(localPlayer.Name);
- end
- function SetWalkspeed(walkspeedValue)
- localPlayer.Character:WaitForChild("Humanoid").WalkSpeed = walkspeedValue;
- end
- function OnRoundStateUpdated(updatedRoundState)
- local isEntrantValue = localPlayer:WaitForChild("PlayerValues").GeneralValues.IsEntrantValue.Value;
- if (isEntrantValue == true) then
- local isMatchFininished = updatedRoundState == "MatchFinished";
- if (isMatchFininished) then
- hasMatchInformationBeenDisplayed = false;
- wait(0.1);
- SetWalkspeed(0);
- else
- setStateBindableEvent:Fire();
- end
- end
- end
- Initialize();
- OnPlayerJoinedMatch(localPlayer.Name);
- shopEnteredBindableEvent.Event:Connect(OnShopEntered);
- shopExitedBindableEvent.Event:Connect(OnShopExited);
- matchInformationDisplayedBindableEvent.Event:Connect(OnMatchInformationDisplayed);
- RoundModule.OnRoundStateUpdated():Connect(OnRoundStateUpdated);
- playerJoinedMatchClientRemoteEvent.OnClientEvent:Connect(OnPlayerJoinedMatch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement