Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- local SodaTable = {}
- --remotes
- local remotes=game.ReplicatedStorage:WaitForChild("Remotes")
- --Folders
- local IG=game.ReplicatedStorage:WaitForChild("InGame")
- local sodaFolder=IG:WaitForChild("Sodas")
- --requiring
- local importances=require(IG:WaitForChild("Importances"))
- local dataman=require(game.ServerScriptService:WaitForChild("Modules"):WaitForChild("DataManager"))
- --Values
- local raritysValue=IG:WaitForChild("Values"):WaitForChild("Rarity")
- local MG=IG:WaitForChild("Values"):WaitForChild("MythicGuaranteed")
- MG.Value=false
- local LG=IG:WaitForChild("Values"):WaitForChild("LegendaryGuaranteed")
- LG.Value=false
- local moneyLost=nil
- local RarityName=nil
- local MutationName=nil
- local number2=nil
- local roundedMPS=nil
- local roundedPrice=nil
- local NameTag=nil
- --Timers
- local sodaTimer=workspace:WaitForChild("SodaSign"):WaitForChild("SodaTimer")
- --Miscellaneous
- local RNG=Random.new();
- --Services
- local ts=game:GetService("TweenService")
- --Scripting
- local rarityTable={
- ["Common"]={"Common",0.5},
- ["Rare"]={"Rare",0.44},
- ["Legendary"]={"Legendary",0.05},
- ["Mythic"]={"Mythic",0.01},
- }
- local mutationTable={
- ["Normal"]={"Normal",0.90},
- ["Golden"]={"Golden",0.06},
- ["Diamond"]={"Diamond",0.03},
- ["Rainbow"]={"Rainbow",0.01},
- }
- task.spawn(function()
- --legendary
- local LMS = 150
- local LRS = LMS
- while true do
- task.wait(1)
- LRS-=1
- local LM = math.floor(LRS/60)
- local LSL = LRS-LM*60
- if LSL<10 then
- sodaTimer.Legendary.Legendary.Text="Guaranteed <font color='rgb(255,255,0)'> Legendary </font> in " .. LM .. ":0" .. LSL
- else
- sodaTimer.Legendary.Legendary.Text="Guaranteed <font color='rgb(255,255,0)'> Legendary </font> in " .. LM .. ":" .. LSL
- end
- if LRS<=0 then
- LRS=LMS
- LG.Value=true
- end
- end
- end)
- task.spawn(function()
- --mythic
- local MMS = 300
- local MRS = MMS
- while true do
- task.wait(1)
- MRS-=1
- local MM = math.floor(MRS/60)
- local MSL = MRS-MM*60
- if MSL<10 then
- sodaTimer.Mythic.Mythic.Text="Guaranteed <font color='rgb(255,0,0)'> Mythic </font> in " .. MM .. ":0" .. MSL
- else
- sodaTimer.Mythic.Mythic.Text="Guaranteed <font color='rgb(255,0,0)'> Mythic </font> in " .. MM .. ":" .. MSL
- end
- if MRS<=0 then
- MRS=MMS
- MG.Value=true
- end
- end
- end)
- function comma_value(amount)
- local formatted, k = amount, nil
- local a, b = "^(-?%d+)(%d%d%d)", '%1,%2'
- repeat
- formatted, k = string.gsub(formatted, a, b)
- until (k == 0)
- return formatted
- end
- local function NPCMove(sodamodel)
- sodamodel:SetPrimaryPartCFrame(workspace.Start.CFrame)
- task.spawn(function()
- local falseTouch=false
- task.spawn(function()
- while true do
- if falseTouch== true then
- break
- elseif not falseTouch then
- if not sodamodel then return end
- sodamodel.Humanoid:MoveTo(workspace.Finish.Position)
- end
- task.wait(5)
- end
- end)
- sodamodel:WaitForChild("IsClaimed"):GetPropertyChangedSignal("Value"):Connect(function()
- print(falseTouch)
- falseTouch=true
- end)
- local TouchFunction
- TouchFunction = sodamodel.ProxPart.Touched:Connect(function(hit)
- if hit.Name=="Finish" then
- TouchFunction:Disconnect()
- falseTouch=true
- task.wait(2)
- if sodamodel:WaitForChild("IsClaimed").Value==true or not sodamodel:WaitForChild("IsClaimed") then return end
- sodamodel:Destroy()
- end
- end)
- end)
- end
- local function chooseRarity()
- local weight=0;
- for i, v in pairs(rarityTable) do
- weight+=rarityTable[i][2]
- end
- local chosen=RNG:NextNumber(0, weight);
- for i, v in pairs(rarityTable) do
- weight-=rarityTable[i][2]
- if chosen>weight then
- print(rarityTable[i][1],rarityTable[i][2])
- RarityName=rarityTable[i][1]
- break
- end
- end
- end
- local function chooseMutations()
- local weight=0;
- for i, v in pairs(mutationTable) do
- weight+=mutationTable[i][2]
- end
- local chosen2=RNG:NextNumber(0, weight);
- for i, v in pairs(mutationTable) do
- weight-=mutationTable[i][2]
- if chosen2>weight then
- MutationName=mutationTable[i][1]
- break
- end
- end
- end
- local function chosenPodium(plr, SodaModelTable, Stringy, IntValue)
- for i = 1, 8 do
- number2=i
- local has = false
- for _, sodaplayer in pairs(plr.Sodas:GetChildren()) do
- if sodaplayer.Value==i then
- has=true
- end
- end
- if not has then
- IntValue.Value=i
- SodaModelTable.Position=i
- SodaModelTable.Mutation=MutationName
- Stringy.Value=SodaModelTable.Mutation
- break
- end
- end
- end
- local function determinePrice(sodamodel)
- if MutationName=="Normal" then
- roundedPrice=math.round(importances.Sodas[sodamodel.Name].Price * 1)
- elseif MutationName=="Golden" then
- roundedPrice=math.round(importances.Sodas[sodamodel.Name].Price * 1.75)
- elseif MutationName=="Diamond" then
- roundedPrice=math.round(importances.Sodas[sodamodel.Name].Price * 2.5)
- elseif MutationName=="Rainbow" then
- roundedPrice=math.round(importances.Sodas[sodamodel.Name].Price * 3.25)
- end
- end
- local function determineMPS(sodamodel)
- if MutationName=="Normal" then
- roundedMPS=math.round(importances.Sodas[sodamodel.Name].MPS * 1)
- elseif MutationName=="Golden" then
- roundedMPS=math.round(importances.Sodas[sodamodel.Name].MPS * 2)
- elseif MutationName=="Diamond" then
- roundedMPS=math.round(importances.Sodas[sodamodel.Name].MPS * 3)
- elseif MutationName=="Rainbow" then
- roundedMPS=math.round(importances.Sodas[sodamodel.Name].MPS * 4)
- end
- end
- local function colorChange(sodamodel)
- for i, v in sodamodel:GetChildren() do
- if v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("WedgePart") or v:IsA("Part") then
- if MutationName=="Rainbow" then
- task.spawn(function()
- while true do
- for i=0,1,0.001*10 do
- v.Color=Color3.fromHSV(i,1,1)
- task.wait()
- end
- end
- end)
- elseif MutationName=="Golden" then
- v.Color=Color3.new(1,1,0)
- elseif MutationName=="Diamond" then
- v.Color=Color3.new(0,1,1)
- end
- end
- end
- end
- local function cloneNameTag(sodamodel)
- if RarityName=="Common" then
- NameTag=IG:WaitForChild("Common"):Clone()
- elseif RarityName=="Rare" then
- NameTag=IG:WaitForChild("Rare"):Clone()
- elseif RarityName == "Legendary" then
- NameTag=IG:WaitForChild("Legendary"):Clone()
- elseif RarityName == "Mythic" then
- NameTag=IG:WaitForChild("Mythic"):Clone()
- end
- NameTag.Parent=sodamodel.HumanoidRootPart
- end
- local function nameTag(sodamodel)
- NameTag:WaitForChild("Mutation").Text=MutationName
- if MutationName=="Normal" then
- NameTag:WaitForChild("Mutation").TextColor3=Color3.fromRGB(255,255,255)
- elseif MutationName=="Golden" then
- NameTag:WaitForChild("Mutation").TextColor3=Color3.fromRGB(255,255,0)
- elseif MutationName=="Diamond" then
- NameTag:WaitForChild("Mutation").TextColor3=Color3.fromRGB(0,255,255)
- elseif MutationName=="Rainbow" then
- NameTag:WaitForChild("Mutation").TextColor3=Color3.fromRGB(255,255,255)
- task.spawn(function()
- while true do
- for i=0,1,0.001*10 do
- NameTag:WaitForChild("Mutation").TextColor3=Color3.fromHSV(i,1,1)
- task.wait()
- end
- end
- end)
- end
- NameTag:WaitForChild("Rarity").Text=importances.Sodas[sodamodel.Name].Rarity
- if RarityName=="Common" then
- NameTag:WaitForChild("Rarity").TextColor3=Color3.fromRGB(255,255,255)
- elseif RarityName=="Rare" then
- NameTag:WaitForChild("Rarity").TextColor3=Color3.fromRGB(21, 185, 255)
- elseif RarityName=="Legendary" then
- NameTag:WaitForChild("Rarity").TextColor3=Color3.fromRGB(255, 255, 0)
- elseif RarityName=="Mythic" then
- NameTag:WaitForChild("Rarity").TextColor3=Color3.fromRGB(255,0,0)
- end
- NameTag:WaitForChild("SodaName").Text=sodamodel.Name
- NameTag:WaitForChild("MPS").Text="$" .. importances.Sodas[sodamodel.Name].MPS .. "/s"
- NameTag:WaitForChild("Price").Text="$" .. importances.Sodas[sodamodel.Name].Price
- NameTag.Parent=sodamodel.HumanoidRootPart
- end
- local function proximityPrompt(sodamodel, price, prox)
- prox.MaxActivationDistance=12
- prox.RequiresLineOfSight=false
- prox.HoldDuration=0.5
- prox.ObjectText=sodamodel.Name
- prox.ActionText="Buy for: $" .. price
- end
- local function moneySubtract(profile, plr, prox)
- if profile.Data.Cash>=moneyLost then
- game.ReplicatedStorage.Remotes.Bought:FireClient(plr, plr.Name, prox, moneyLost)
- profile.Data.Cash-=moneyLost
- moneyLost+=moneyLost
- plr.leaderstats.Cash.Value=profile.Data.Cash
- print(profile.Data.Cash)
- end
- end
- local function chanceSystem()
- chooseRarity()
- chooseMutations()
- for i, v in pairs(importances.Sodas) do
- if v.Rarity==RarityName then
- table.insert(SodaTable,i)
- end
- end
- local randomSoda=SodaTable[math.random(1,#SodaTable)]
- local sodamodel = sodaFolder:FindFirstChild(randomSoda):Clone()
- local prox = Instance.new("ProximityPrompt", sodamodel.HumanoidRootPart)
- if not sodamodel then return end
- local Owner=nil
- sodamodel.Parent=workspace
- sodamodel.PrimaryPart:SetNetworkOwner(nil)
- cloneNameTag(sodamodel)
- determineMPS(sodamodel)
- determinePrice(sodamodel)
- proximityPrompt(sodamodel, roundedPrice, prox)
- nameTag(sodamodel)
- if sodamodel.Parent==workspace then
- NPCMove(sodamodel)
- end
- colorChange(sodamodel)
- prox.Triggered:Connect(function(plr)
- local profile=dataman.Profile[plr]
- local TotalSlots=#profile.Data.Sodas
- moneyLost=importances.Sodas[sodamodel.Name].Price
- print(TotalSlots)
- if TotalSlots<8 then
- if profile.Data.Cash>=moneyLost then
- moneySubtract(profile,plr,prox)
- Owner=plr.Name
- local hum = sodamodel:FindFirstChild("Humanoid")
- local connection=nil
- local ConnectionNow=nil
- sodamodel.IsClaimed.Value=true
- for i, v in workspace:WaitForChild("Bases"):GetChildren() do
- if v.Name==plr.Name and v.PlayerSign.PlayerName.Value==Owner and Owner==plr.Name then
- task.spawn(function()
- local stillMoving
- task.spawn(function()
- repeat
- hum:MoveTo(v.CashMultiplier.Touch.Position)
- stillMoving=hum.MoveToFinished:Wait()
- until stillMoving
- end)
- ConnectionNow = v.CashMultiplier.Touch.Touched:Connect(function(hit)
- if hit.Parent.Name==sodamodel.Name then
- local SodaModelTable = {}
- SodaModelTable.Name=sodamodel.Name
- SodaModelTable.Position = 0
- local IntValue=Instance.new("IntValue")
- IntValue.Name=sodamodel.Name
- local Stringy=Instance.new("StringValue",IntValue)
- Stringy.Name="Mutation"
- table.insert(profile.Data.Sodas,SodaModelTable)
- chosenPodium(plr, SodaModelTable, Stringy, IntValue)
- local cloneSoda
- local cloneSodaName
- ConnectionNow:Disconnect()
- task.wait(0.3)
- if SodaModelTable.Position==number2 then
- for blah, Soda in sodaFolder:GetChildren() do
- if Soda:IsA("Model") and Soda.Name == SodaModelTable.Name then
- cloneSoda=Soda:Clone()
- cloneSoda.Parent=v
- cloneSodaName=cloneSoda.Name
- for blahblah, parts in cloneSoda:GetDescendants() do
- if parts:IsA("Part") or parts:IsA("MeshPart") or parts:IsA("WedgePart") or parts:IsA("UnionOperation") then
- parts.Anchored=true
- parts.CanCollide=false
- end
- end
- end
- end
- end
- cloneSoda:PivotTo(v.Podiums["Podium"..number2].SodaTP.CFrame - Vector3.new(0,3,0))
- local proxPrompt=Instance.new("ProximityPrompt",cloneSoda)
- proxPrompt.Name="ProximityPrompt"
- proxPrompt.HoldDuration=2
- game.ReplicatedStorage.Remotes.Steal:FireClient(plr, cloneSoda.Name, plr.Name, proxPrompt)
- IntValue.Parent=plr.Sodas
- colorChange(cloneSoda)
- for _, v in sodamodel.HumanoidRootPart:GetChildren() do
- if v:IsA("BillboardGui") then
- v.Parent=cloneSoda.HumanoidRootPart
- end
- end
- local cash
- if MutationName=="Normal" then
- cash=math.round((importances.Sodas[sodamodel.Name].MPS * 1) * profile.Data.CashMultiplier)
- elseif MutationName=="Golden" then
- cash=math.round((importances.Sodas[sodamodel.Name].MPS * 2) * profile.Data.CashMultiplier)
- elseif MutationName=="Diamond" then
- cash=math.round((importances.Sodas[sodamodel.Name].MPS * 3) * profile.Data.CashMultiplier)
- elseif MutationName=="Rainbow" then
- cash=math.round((importances.Sodas[sodamodel.Name].MPS * 4) * profile.Data.CashMultiplier)
- end
- sodamodel:Destroy()
- task.spawn(function()
- while task.wait(1) do
- if v:FindFirstChild(cloneSodaName) then
- v.Podiums["Podium"..number2].Collect.Money.Value+=cash
- v.Podiums["Podium"..number2].Collect.BillboardGui.TextLabel.Text="Collect: $" .. comma_value(v.Podiums["Podium"..number2].Collect.Money.Value)
- end
- end
- end)
- task.spawn(function()
- while task.wait() do
- if not v:FindFirstChild(cloneSodaName) then
- profile.Data.Cash+=v.Podiums["Podium"..number2].Collect.Money.Value
- game.ReplicatedStorage.Remotes.Gained:FireClient(plr, v.Podiums["Podium"..number2].Collect.Money.Value)
- plr.leaderstats.Cash.Value=profile.Data.Cash
- v.Podiums["Podium"..number2].Collect.Money.Value=0
- v.Podiums["Podium"..number2].Collect.BillboardGui.TextLabel.Text="Collect: $" .. comma_value(v.Podiums["Podium"..number2].Collect.Money.Value)
- end
- end
- end)
- v.Podiums["Podium"..number2].Collect.Touched:Connect(function(hit)
- local plr2=game.Players:GetPlayerFromCharacter(hit.Parent)
- if plr2 and plr2.Name==v.Name and plr2.Name==tostring(v.PlayerSign.PlayerName.Value) then
- profile.Data.Cash+=v.Podiums["Podium"..number2].Collect.Money.Value
- game.ReplicatedStorage.Remotes.Gained:FireClient(plr2, v.Podiums["Podium"..number2].Collect.Money.Value)
- plr2.leaderstats.Cash.Value=profile.Data.Cash
- v.Podiums["Podium"..number2].Collect.Money.Value=0
- v.Podiums["Podium"..number2].Collect.BillboardGui.TextLabel.Text="Collect: $" .. comma_value(v.Podiums["Podium"..number2].Collect.Money.Value)
- end
- end)
- end
- end)
- end)
- end
- end
- elseif profile.Data.Cash<importances.Sodas[sodamodel.Name].Price then
- game.ReplicatedStorage.Remotes.Alert:FireClient(plr, "LowOnMoney")
- end
- elseif TotalSlots>=8 then
- game.ReplicatedStorage.Remotes.Alert:FireClient(plr,"MaxSodas")
- end
- end)
- end
- task.spawn(function()
- while task.wait(3) do
- chanceSystem()
- end
- end)
- return module
Advertisement
Add Comment
Please, Sign In to add comment