Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dss = game:GetService("DataStoreService")
- local RedButton = dss:GetDataStore("RedTrail")
- local YellowButton = dss:GetDataStore("YellowTrail")
- local GreenButton = dss:GetDataStore("GreenTrail")
- local BlueButton = dss:GetDataStore("BlueTrail")
- local BlackButton = dss:GetDataStore("BlackTrail")
- local RainbowButton = dss:GetDataStore("RainbowTrail")
- local rs = game:GetService("ReplicatedStorage")
- local function buy(player, click, amount)
- -- Check For Previous Trails
- local prevTrail = player.Character.Head:FindFirstChildWhichIsA("Trail")
- -- Destroys Previous Trails If Not Nil
- if prevTrail then
- local prevA0 = player.Character.Head:FindFirstChild(prevTrail.Name.."TrailA0")
- local prevA1 = player.Character.HumanoidRootPart:FindFirstChild(prevTrail.Name.."TrailA1")
- prevTrail:Destroy()
- prevA0:Destroy()
- prevA1:Destroy()
- end
- -- Clones Bought Trail And Creates Attachments
- local clone = rs:WaitForChild("Trails"):FindFirstChild(click.Name):Clone()
- clone.Parent = player.Character.Head
- local a0 = Instance.new("Attachment", player.Character.Head)
- a0.Name = click.Name.."TrailA0"
- local a1 = Instance.new("Attachment", player.Character.HumanoidRootPart)
- a1.Name = click.Name.."TrailA1"
- clone.Attachment0 = a0
- clone.Attachment1 = a1
- --Decrease Cash
- player:WaitForChild("leaderstats").Coins.Value = player:WaitForChild("leaderstats").Coins.Value - amount
- return true
- end
- rs.BuyTrail.OnServerInvoke = function(plr, button, cost)
- if plr:WaitForChild("leaderstats").Coins.Value >= cost then
- if button.Name == "RedButton" then
- local data = RedButton:GetAsync(plr.UserId)
- local bought = false
- if data then
- bought = true
- else
- bought = false
- end
- if bought == false then
- buy(plr, button, cost)
- RainbowButton:SetAsync(plr.UserId, true)
- end
- end
- -----------------------------------------------------------------------------------------------
- if button.Name == "YellowButton" then
- local data = YellowButton:GetAsync(plr.UserId)
- local bought = false
- if data then
- bought = true
- else
- bought = false
- end
- if bought == false then
- buy(plr, button, cost)
- RainbowButton:SetAsync(plr.UserId, true)
- end
- end
- -----------------------------------------------------------------------------------------------
- if button.Name == "GreenButton" then
- local data = GreenButton:GetAsync(plr.UserId)
- local bought = false
- if data then
- bought = true
- else
- bought = false
- end
- if bought == false then
- buy(plr, button, cost)
- RainbowButton:SetAsync(plr.UserId, true)
- end
- end
- -----------------------------------------------------------------------------------------------
- if button.Name == "BlueButton" then
- local data = BlueButton:GetAsync(plr.UserId)
- local bought = false
- if data then
- bought = true
- else
- bought = false
- end
- if bought == false then
- buy(plr, button, cost)
- RainbowButton:SetAsync(plr.UserId, true)
- end
- end
- -----------------------------------------------------------------------------------------------
- if button.Name == "BlackButton" then
- local data = BlackButton:GetAsync(plr.UserId)
- local bought = false
- if data then
- bought = true
- else
- bought = false
- end
- if bought == false then
- buy(plr, button, cost)
- RainbowButton:SetAsync(plr.UserId, true)
- end
- end
- -----------------------------------------------------------------------------------------------
- if button.Name == "RainbowButton" then
- local data = RainbowButton:GetAsync(plr.UserId)
- local bought = false
- if data then
- bought = true
- else
- bought = false
- end
- if bought == false then
- buy(plr, button, cost)
- RainbowButton:SetAsync(plr.UserId, true)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment