Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make your own particle game pass?

Asked by 6 years ago
Edited 6 years ago

I am trying to create my own particle for players to buy a gamepass and get.

I have the premade particles from roblox working. Script:

local passId = 000000000

function isAuthenticated(player)
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end

game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
        plr.CharacterAdded:connect(function(char)
            local Trail1 = Instance.new("Sparkles")
            Trail1.Parent = char:WaitForChild("Left Leg")
            local Trail2 = Instance.new("Sparkles")
            Trail2.Parent = char:WaitForChild("Right Leg")
        end)
    end
end)

And I have created my custom particle and placed it in replicated storage, I used this script to test it for when I touch a block.

local rs = game:GetService("ReplicatedStorage")

function onTouch(hit)
    local ee = rs.ParticleEmitter:Clone()

    if hit.Parent.Torso:FindFirstChild("ParticleEmitter")then
        hit.Parent.Torso.ParticleEmitter:remove()
    end
    ee.Parent = hit.Parent.Torso
    end

script.Parent.Touched:connect(onTouch)

But no I am trying to make it so that you get my custom particle when you purchase a gamepass, this is what I have so far, and I am not sure what to do from now.

local passId = 000000000

function isAuthenticated(player)
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end

local particles = game.ReplicatedStorage.Particles
game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then

Any help would be much apreciated thank you :)

1 answer

Log in to vote
1
Answered by 6 years ago

Instead of using MarketPlaceService to check if a player has a gamepass you should use GamePassService. And check if they have the pass in the function itself. So then your first block of code would look like this


local passId = 000000000 local GamePassService = game:GetService('GamePassService') game.Players.PlayerAdded:connect(function(plr) if GamePassService:PlayerHasPass(plr,passId) then plr.CharacterAdded:connect(function(char) local Trail1 = Instance.new("Sparkles") Trail1.Parent = char:WaitForChild("Left Leg") local Trail2 = Instance.new("Sparkles") Trail2.Parent = char:WaitForChild("Right Leg") end) end end)

Your second script looks fine

Your last script is it meant to suddenly end at 'then' because then it wont work.

0
No I'm not sure what to do after 'then' Pot8o_Penguin 50 — 6y
Ad

Answer this question