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

Make this script Gamepass activated?

Asked by 6 years ago

I want to make this function in my script only run for a player if they have a Gamepass.

local player = script.Parent
local trail = game.ReplicatedStorage.TrailMachine

function createMachine()
    local trailClone = trail:Clone()
    trailClone.PrimaryPart = trailClone.Core
    trailClone.Parent = player
    trailClone:moveTo(player.Torso.Position)

    local weld = Instance.new("Motor6D")
    weld.Parent = trailClone.Core
    weld.Part0 = trailClone.Core
    weld.Part1 = player.Torso
end

Any help would be appreciated

2 answers

Log in to vote
0
Answered by
piRadians 297 Moderation Voter
6 years ago
Edited 6 years ago

Use the PlayerAdded event and check if they have a certain gamepass using the method UserOwnsGamePassAsync.


local trail = game.ReplicatedStorage.TrailMachine mps= game:GetService("MarketPlaceService") function createMachine() local trailClone = trail:Clone() trailClone.PrimaryPart = trailClone.Core trailClone.Parent = player trailClone:moveTo(player.Torso.Position) local weld = Instance.new("Motor6D") weld.Parent = trailClone.Core weld.Part0 = trailClone.Core weld.Part1 = player.Torso end game:GetService("Players").PlayerAdded:Connect(function(player) if mps:UserOwnsGamePassAsync(player.UserId,passID) then createMachine(player) end end)
0
I replaced "passID" with the gamepass id, but the function still isn't running. Starflyerz 44 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

local id =

if game.MarketplaceService:UserOwnsGamePassAsync(player.UserId,id) then

-- function

end

Answer this question