Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- local replicatedStorage = game.ReplicatedStorage
- local shopFrameButton = script.Parent
- local trailsData = replicatedStorage.Trails
- local Redtrail = game.ReplicatedStorage.Trails:FindFirstChild("Red")
- -- Function to setup the trail
- function trailsSetup(dataFolder)
- for index, trail in pairs(dataFolder:GetChildren()) do
- --local trailFrame = shopFrameButton.Parent(trail.Name,trail.Price.Value,trail.Color)
- -- Update your inventory
- if game.Players.LocalPlayer.TrailInventory:FindFirstChild(Redtrail.Name) then
- shopFrameButton.TrailPrice.Text = "Owned"
- print(trail.Name)
- end
- -- Update your equipped Trail
- if game.Players.LocalPlayer.EquippedTrail.Value == Redtrail.Name then
- shopFrameButton.TrailPrice.Text = "Equipped"
- print(trail.Name)
- end
- shopFrameButton.MouseButton1Click:Connect(function()
- local result = replicatedStorage.Events.BuyItem2:InvokeServer(Redtrail.Name)
- if result == "Brought" then
- shopFrameButton.TrailPrice.Text = "Owned"
- elseif result == "NotEnough" then
- shopFrameButton.TrailPrice.Text = "Not Enough Coins"
- wait(.5)
- shopFrameButton.TrailPrice.Text = "100 Coins"
- elseif result == "Equip" then
- shopFrameButton.TrailPrice.Text = "Equipped"
- elseif result == "Unequip" then
- shopFrameButton.TrailPrice.Text = "Owned"
- end
- end)
- end
- end
- -- If data is loaded up, it will bring your items
- replicatedStorage.Events.SendData.OnClientEvent:Connect(function()
- trailsSetup(trailsData)
- end)
Add Comment
Please, Sign In to add comment