Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ServerScriptService = game:GetService("ServerScriptService")
- local MarketplaceService = game:GetService("MarketplaceService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local EndMatch = game.ServerScriptService.Network.EndMatch
- local LocalNetwork = ReplicatedStorage.LocalNetwork
- local P2N = LocalNetwork.P2N
- local SpawnEvent = LocalNetwork.Spawn
- local HealthChange = LocalNetwork.HealthChange
- local Chars = ReplicatedStorage.Chars:GetChildren()
- local Charss = game.ReplicatedStorage:WaitForChild("Chars")
- local CharSelectorUI = game.StarterGui.CharSelector
- local CharSelectorMain = game.StarterGui.CharSelector.Main
- local Sample = CharSelectorMain.CharSelect.List.Store.Sample
- local PGS = {
- PG1 = 806554024,
- PG2 = 807124029,
- PG3 = 806655018,
- SPG = 806916035,
- }
- game.Players.PlayerAdded:Connect(function(Player)
- local CharName = Instance.new("StringValue")
- CharName.Name = "CName"
- CharName.Parent = Player
- --local CharPos = Instance.new("BoolValue")
- --CharPos.Name = "OnLeft"
- --CharPos.Parent = Player
- local SpValue = Instance.new("BoolValue")
- SpValue.Name = "Spawn"
- SpValue.Parent = Player
- local SP1Value = Instance.new("BoolValue")
- SP1Value.Name = "Spawn1"
- SP1Value.Parent = Player
- local SP2Value = Instance.new("BoolValue")
- SP2Value.Name = "Hit"
- SP2Value.Parent = Player
- game.Players:GetPlayers()[1].Character.PrimaryPart.CFrame = workspace.Model.Spawn1.CFrame + Vector3.new(0, 4, 0)
- game.Players:GetPlayers()[2].Character.PrimaryPart.CFrame = workspace.Model.Spawn2.CFrame + Vector3.new(0, 4, 0)
- end)
- for I, V in ipairs(Chars) do
- local VPF = Instance.new("ViewportFrame")
- VPF.Parent = CharSelectorMain.CharSelect.List
- VPF.Name = V.Name
- VPF.BackgroundTransparency = 1
- VPF.AnchorPoint = Vector2.new(0.5,0.5)
- VPF.Position = UDim2.new(0.5, 0, 0.5, 0)
- VPF.Size = UDim2.new(1,0,1,0)
- local CChar = V.StarterCharacter:Clone()
- CChar.Parent = VPF
- local BTN = Sample:Clone()
- BTN.Visible = true
- BTN.Parent = VPF
- BTN.Name = V.Name
- BTN.Size = UDim2.new(1,0,1,0)
- BTN.Position = UDim2.new(0.5, 0, 0.5, 0)
- BTN.ImageColor3 = V:GetAttribute("Color")
- BTN.AnchorPoint = Vector2.new(0.5,0.5)
- BTN.Text.Text = V.StarterCharacter:GetAttribute("CHAR")
- BTN:AddTag("CharButton")
- BTN:AddTag("Button")
- if I < 5 then
- BTN:SetAttribute("Own", true)
- end
- if I > 4 then
- local h,s,v = BTN.ImageColor3:ToHSV()
- v = 0.43137258291244507
- local newcolor = Color3.fromHSV(h,s,v)
- BTN.ImageColor3 = newcolor
- BTN.Interactable = true
- end
- end
- local function CheckPas(Player)
- for I, V in pairs(PGS) do
- local HasPG = false
- local success, message = pcall(function()
- HasPG = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, V)
- end)
- if not success then
- warn("Error while checking if player has pass: " .. tostring(message))
- return
- end
- task.delay(2, function()
- if HasPG then
- local List = Player.PlayerGui:WaitForChild("CharSelector").Main.CharSelect.List
- if I == "PG1" then
- List["FairyMan"]["FairyMan"].ImageColor3 = Charss["FairyMan"]:GetAttribute("Color")
- List["FairyWoman"]["FairyWoman"].ImageColor3 = Charss["FairyWoman"]:GetAttribute("Color")
- List["FairyWoman"]["FairyWoman"]:SetAttribute("Own", true)
- List["FairyMan"]["FairyMan"]:SetAttribute("Own", true)
- end
- if I == "PG2" then
- List["Ninja"]["Ninja"].ImageColor3 = Charss["Ninja"]:GetAttribute("Color")
- List["Samurai"]["Samurai"].ImageColor3 = Charss["Samurai"]:GetAttribute("Color")
- List["Ninja"]["Ninja"]:SetAttribute("Own", true)
- List["Samurai"]["Samurai"]:SetAttribute("Own", true)
- end
- if I == "PG3" then
- List["SPMan"]["SPMan"].ImageColor3 = Charss["SPMan"]:GetAttribute("Color")
- List["SPWoman"]["SPWoman"].ImageColor3 = Charss["SPWoman"]:GetAttribute("Color")
- List["SPMan"]["SPMan"]:SetAttribute("Own", true)
- List["SPWoman"]["SPWoman"]:SetAttribute("Own", true)
- end
- if I == "SPG" then
- List["Vampire"]["Vampire"].ImageColor3 = Charss["Vampire"]:GetAttribute("Color")
- List["WizWoman"]["WizWoman"].ImageColor3 = Charss["WizWoman"]:GetAttribute("Color")
- List["WizardMan"]["WizardMan"].ImageColor3 = Charss["WizardMan"]:GetAttribute("Color")
- List["Vampire"]["Vampire"]:SetAttribute("Own", true)
- List["WizWoman"]["WizWoman"]:SetAttribute("Own", true)
- List["WizardMan"]["WizardMan"]:SetAttribute("Own", true)
- end
- end
- end)
- local Pass = Player:WaitForChild("Inv").Pass.Value
- print(Pass, "THE PASS VALUE")
- task.delay(4, function()
- print(Pass, "THE PASS VALUE after the delay")
- if Pass == 1 then
- local List = Player.PlayerGui:WaitForChild("CharSelector").Main.CharSelect.List
- for _, V in ipairs(List:GetDescendants()) do
- if V:IsA("ImageButton") and V.Name ~= "Sample" then
- V:SetAttribute("Own", true)
- V.ImageColor3 = Charss[V.Name]:GetAttribute("Color")
- end
- end
- end
- end)
- end
- end
- game.Players.PlayerAdded:Connect(function(Player)
- wait()
- CheckPas(Player)
- end)
- MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, purchasedPassID, purchaseSuccess)
- print("PURCHASE IS CALLED")
- if purchaseSuccess then
- print("PURCHASE IS SUCCESS 1")
- CheckPas(Player)
- print("PURCHASE IS SUCCESS 2")
- end
- end)
- P2N.OnServerEvent:Connect(function(Player, CharN)
- P2N:FireAllClients(Player, CharN)
- if Player ~= game.Players:GetPlayers()[1] then
- local btns = game.Players:GetPlayers()[1].PlayerGui.CharSelector.Main.CharSelect.List:GetDescendants()
- for _, V in ipairs(btns) do
- if V:IsA("ImageButton") then
- if V.Name ~= CharN and V.Parent:IsA("ViewportFrame") then
- local CC = game.ReplicatedStorage.Chars[V.Name]
- if V:GetAttribute("Own") then
- V.ImageColor3 = CC:GetAttribute("Color")
- V.Interactable = true
- else
- local C = CC:GetAttribute("Color")
- local h,s,v = C:ToHSV()
- v = 0.43137258291244507
- local newcolor = Color3.fromHSV(h,s,v)
- V.Interactable = true
- V.ImageColor3 = newcolor
- end
- elseif V.Name == CharN then
- V.Interactable = false
- V.ImageColor3 = Color3.fromRGB(120, 0, 0)
- end
- end
- end
- end
- if Player ~= game.Players:GetPlayers()[2] then
- local btns = game.Players:GetPlayers()[2].PlayerGui.CharSelector.Main.CharSelect.List:GetDescendants()
- for _, V in ipairs(btns) do
- if V:IsA("ImageButton") then
- if V.Name ~= CharN and V.Parent:IsA("ViewportFrame") then
- local CC = game.ReplicatedStorage.Chars[V.Name]
- if V:GetAttribute("Own") then
- V.ImageColor3 = CC:GetAttribute("Color")
- V.Interactable = true
- else
- local C = CC:GetAttribute("Color")
- local h,s,v = C:ToHSV()
- v = 0.43137258291244507
- local newcolor = Color3.fromHSV(h,s,v)
- V.Interactable = true
- V.ImageColor3 = newcolor
- end
- elseif V.Name == CharN then
- V.Interactable = false
- V.ImageColor3 = Color3.fromRGB(120, 0, 0)
- end
- end
- end
- end
- end)
- local charsFolder = game.ReplicatedStorage.Chars
- local Numb = 0
- local Player1IsReady = false
- local Player2IsReady = false
- SpawnEvent.OnServerEvent:Connect(function(Player, ChosenCharacter, Action)
- Numb += 1
- local newChar
- if Player == game.Players:GetPlayers()[1] then
- newChar = charsFolder:FindFirstChild(ChosenCharacter)["StarterCharacter" .. Numb]
- print("Spawning for the " .. Numb .. " Time ...")
- Player1IsReady = true
- Player.RespawnLocation = workspace.Model.Spawn1
- game.Players:GetPlayers()[1].Character.PrimaryPart.CFrame = workspace.Model.Spawn1.CFrame + Vector3.new(0, 4, 0)
- game.Players:GetPlayers()[2].Character.PrimaryPart.CFrame = workspace.Model.Spawn2.CFrame + Vector3.new(0, 4, 0)
- game.Players:GetPlayers()[1].Character.Humanoid.Health = 100
- game.Players:GetPlayers()[2].Character.Humanoid.Health = 100
- end
- if Player == game.Players:GetPlayers()[2] then
- newChar = charsFolder:FindFirstChild(ChosenCharacter)["StarterCharacter" .. Numb]
- print("Spawning for the " .. Numb .. " Time ...")
- Player2IsReady = true
- Player.RespawnLocation = workspace.Model.Spawn2
- game.Players:GetPlayers()[2].Character.PrimaryPart.CFrame = workspace.Model.Spawn2.CFrame + Vector3.new(0, 4, 0)
- game.Players:GetPlayers()[1].Character.PrimaryPart.CFrame = workspace.Model.Spawn1.CFrame + Vector3.new(0, 4, 0)
- game.Players:GetPlayers()[2].Character.Humanoid.Health = 100
- game.Players:GetPlayers()[1].Character.Humanoid.Health = 100
- end
- local Character = Player.Character
- if newChar:FindFirstChild("HumanoidRootPart") then
- newChar.PrimaryPart = newChar.HumanoidRootPart
- newChar:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame)
- elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
- newChar.PrimaryPart = newChar.Torso
- newChar:SetPrimaryPartCFrame(Character.Torso.CFrame)
- end
- if Player.Character:FindFirstChild("Animate") then
- local anim = Player.Character:FindFirstChild("Animate"):Clone()
- anim.Parent = newChar
- end
- newChar.Name = Player.Name
- Player.Character = newChar
- local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
- local plrRoot = Player.Character:FindFirstChild("HumanoidRootPart") or Player.Character:FindFirstChild("Torso")
- if rootPart and plrRoot then
- rootPart.CFrame = plrRoot.CFrame
- end
- for _, V in ipairs(Character:GetChildren()) do
- if V:IsA("LocalScript") or V:IsA("Script") then
- V.Parent = newChar
- end
- end
- newChar.Parent = workspace
- local hrp1 = game.Players:GetPlayers()[1].Character.HumanoidRootPart
- local hrp2 = game.Players:GetPlayers()[2].Character.HumanoidRootPart
- game.Players:GetPlayers()[1].Character.HumanoidRootPart.CFrame = CFrame.new(hrp1.Position, hrp2.Position)
- game.Players:GetPlayers()[2].Character.HumanoidRootPart.CFrame = CFrame.new(hrp2.Position, hrp1.Position)
- if Player1IsReady and Player2IsReady then
- SpawnEvent:FireAllClients()
- Player1IsReady = false
- Player2IsReady = false
- print("Count Started")
- EndMatch:Fire("ENDGAME")
- end
- game.Players:GetPlayers()[1].Character:WaitForChild("Torso").CollisionGroup = "Torso"
- game.Players:GetPlayers()[2].Character:WaitForChild("Torso").CollisionGroup = "Torso"
- end)
- HealthChange.OnServerEvent:Connect(function(Player, HPPercentage, Health)
- -- print(Player, HPPercentage, Health)
- HealthChange:FireAllClients(Player.Name, HPPercentage, Health)
- end)
Advertisement
Add Comment
Please, Sign In to add comment