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

How to make this gamepass bus spawn script work?

Asked by 3 years ago

So I am Making a game where you drive buses around and I have made a gamepads to buy a golden bus. I think I have done everything right but it isn't working... Here is the script:

game.Players.PlayerAdded:Connect (function(player)
    if game.MarketplaceService:PlayerOwnsAsset(player,11136750) then
    location = game.Workspace
regen = game.ServerStorage.Buses.GoldenBus
save = regen:clone()
back = nil
function onClicked()
if back ~= nil then
back:remove()
end
back = save:clone()
back.Parent = location
back:MakeJoints()
end
    end
end)

1 answer

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
3 years ago

Use UserOwnsGamePassAsync.

game.Players.PlayerAdded:Connect (function(player)
    if game.MarketplaceService:UserOwnsGamePassAsync(player, 11136750) then -- if it's a gamepass, you have to use that. if it's an asset like a model/hat, you'll use playerownsasset
    location = game.Workspace
regen = game.ServerStorage.Buses.GoldenBus
save = regen:clone()
back = nil
function onClicked()
if back ~= nil then
back:remove()
end
back = save:clone()
back.Parent = location
back:MakeJoints()
end
    end
end)
Ad

Answer this question