Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server Side
- local trails = script.Parent:GetDescendants()
- local debounce = true
- local debounce2 = true
- --print(trails)
- game.Players.PlayerAdded:Connect(function(player)
- wait(1)
- local VisualScript = script.LocalScript:Clone()
- VisualScript.Parent = player.PlayerGui
- VisualScript.Disabled = false
- player.CharacterAdded:Connect(function(Character)
- wait(1)
- local VisualScript = script.LocalScript:Clone()
- VisualScript.Parent = player.PlayerGui
- VisualScript.Disabled = false
- end)
- for i, v in pairs(trails)do
- if v:IsA("Trail") and v.Name == "Trail" then
- if player then
- --print(player.Name) -- it finds the player
- wait(0.5)
- --print(player.EquippedTrail.Value) -- its nil?
- --print(v.Parent.Name == player.EquippedTrail.Value) -- its false
- if v.Parent.Name == player.EquippedTrail.Value and debounce2 then
- debounce2 = false
- --print("Trail Loaded!!")
- local attachment1 = Instance.new("Attachment",player.Character:FindFirstChild("HumanoidRootPart"))
- local attachment2 = Instance.new("Attachment",player.Character:FindFirstChild("Head"))
- local trail = v:Clone()
- trail.Parent = player.Character
- trail.Attachment0 = attachment1
- trail.Attachment1 = attachment2
- wait(1)
- debounce2 = true
- end
- end
- player.CharacterAdded:Connect(function(Character)
- if v.Parent.Name == player.EquippedTrail.Value then
- -- print("trail will copy")
- local attachment1 = Instance.new("Attachment",Character:FindFirstChild("HumanoidRootPart"))
- local attachment2 = Instance.new("Attachment",Character:FindFirstChild("Head"))
- local trail = v:Clone()
- trail.Parent = Character
- trail.Attachment0 = attachment1
- trail.Attachment1 = attachment2
- end
- end)
- end
- end
- end)
- -- these 2 nested for loops get all of the Trails,names and prices when you first join
- for i, name in pairs(trails)do
- if name:IsA("TextLabel") and name.Name == "Name" then
- name.Text = name.Parent.Parent.Parent.Name
- for i, prices in pairs(trails)do
- if prices:IsA("TextLabel") and prices.Name == "Price" then
- prices.Text = prices.Parent.Parent.Parent:FindFirstChild("Price").Value.. " Robux"
- end
- end
- end
- end
- for i,v in pairs(trails)do
- --print(trails) -- gets a table of all objects
- --print(v)-- prints all objects
- if v:IsA("Part") and v.Name == "TouchPad" then
- for i, p in pairs(trails)do
- v.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- local character = player.Character
- if p:IsA("Model") and v.Parent and debounce then
- debounce = false
- --print(v.Parent)
- --print(player)
- --print(p.Value)
- local id = v.Parent:FindFirstChild("GamepassId").Value
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- -- local ProductInfo = game:GetService("MarketplaceService"):GetProductInfo(id, Enum.InfoType.Product)
- -- local Price = ProductInfo.PriceInRobux
- local success, errormessage = pcall(ownsGamepass);
- -- print(id) -- returns the id of the pass!!
- -- print(ProductInfo)
- -- print(ownsGamepass) -- it returns true!!
- -- the whatever below is a simple experiment
- --[[local function TrailNamePrice()
- for i, prices in pairs(trails)do
- if prices:IsA("TextLabel") and prices.Name == "Price" then
- if character:FindFirstChild("Trail") and ownsGamepass then
- v.Parent:FindFirstChild("GroupTag"):FindFirstChild("Frame"):FindFirstChild("Price").Text = "Equipped"
- print(prices.Parent "1")
- end
- if not character:FindFirstChild("Trail") and ownsGamepass then
- v.Parent:FindFirstChild("GroupTag"):FindFirstChild("Frame"):FindFirstChild("Price").Text = "Owned"
- print(prices.Parent "2")
- end
- if not character:FindFirstChild("Trail") and not ownsGamepass then
- prices.Text = prices.Parent.Parent.Parent:FindFirstChild("Price").Value.. " Robux"
- print(prices.Parent "3")
- end
- end
- end
- end
- TrailNamePrice()
- end--]]
- if player and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) ~= true then
- local id2 = v.Parent:FindFirstChild("GamepassId").Value
- print(game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id))
- -- print("I dont own the gamepass ".. id2)
- game:GetService("MarketplaceService"):PromptGamePassPurchase(player,id)
- -- v.Parent:FindFirstChild("GroupTag"):FindFirstChild("Frame"):FindFirstChild("Price").Text = v.Parent.Price.Value " Robux"
- end
- if ownsGamepass and player then
- for i, t in pairs(character:GetChildren())do
- if character.HumanoidRootPart:FindFirstChild("Attachment") then character.HumanoidRootPart.Attachment:Destroy() end
- if character.Head:FindFirstChild("Attachment") then character.Head.Attachment:Destroy() end
- if character.Torso:FindFirstChild("Attachment") then character.Torso.Attachment:Destroy() end
- if character:FindFirstChild(player.Name.."'s Trail") then character[player.Name.."'s Trail"]:Destroy() end
- if t:IsA("Trail") and t.Name == "Trail" and character:FindFirstChild("Trail") then
- character:FindFirstChild("Trail"):Destroy()
- player:FindFirstChild("EquippedTrail").Value = ""
- -- print("Destroying")
- -- v.Parent:FindFirstChild("GroupTag"):FindFirstChild("Frame"):FindFirstChild("Price").Text = "Owned"
- break
- end
- if not character:FindFirstChild("Trail") then
- local attachment1 = Instance.new("Attachment",character:FindFirstChild("HumanoidRootPart"))
- local attachment2 = Instance.new("Attachment",character:FindFirstChild("Head"))
- local trail = v.Parent:FindFirstChild("Trail"):Clone()
- trail.Parent = character
- trail.Attachment0 = attachment1
- trail.Attachment1 = attachment2
- player:FindFirstChild("EquippedTrail").Value = v.Parent.Name
- -- print("Cloning")
- -- v.Parent:FindFirstChild("GroupTag"):FindFirstChild("Frame"):FindFirstChild("Price").Text = "Equipped"
- break
- end
- end
- end
- wait(1)
- debounce = true
- end
- end)
- end
- end
- end
- -- Client Side!!!
- local player = game.Players.LocalPlayer
- local debounce = true
- local trails = game.Workspace.Trails:GetDescendants()
- for i, v in pairs(trails)do
- if v:IsA("Part") and v.Name == "TouchPad" then
- v.Touched:Connect(function(hit)
- if player and debounce then
- debounce = false
- local id = v.Parent.GamepassId.Value
- local price = v.Parent.Price
- local Text = v.Parent.GroupTag.Frame.Price
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- local Character = player.Character
- --print(v.Parent.Name)
- if ownsGamepass then
- if not Character:FindFirstChild("Trail") then
- Text.Text = "Equipped"
- end
- if Character:FindFirstChild("Trail") then
- Text.Text = "Owned"
- end
- end
- wait(1)
- debounce = true
- end
- end)
- end
- end
- local debounce2 = true
- while wait() do
- for i, v in pairs(trails)do
- if v:IsA("Part") and v.Name == "TouchPad" then
- local id = v.Parent.GamepassId.Value
- local price = v.Parent.Price
- local Text = v.Parent.GroupTag.Frame.Price
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- local Character = player.Character
- if ownsGamepass and v.Parent.Name == player.EquippedTrail.Value and debounce2 then
- debounce = false
- Text.Text = "Equipped"
- -- break
- wait(0.1)
- debounce = true
- end
- if ownsGamepass and v.Parent.Name ~= player.EquippedTrail.Value and debounce2 then
- debounce = false
- Text.Text = "Owned"
- wait(0.1)
- debounce = true
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment