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

How do i script a gamepass vehicle spawner?

Asked by
RLX_Dev -5
4 years ago

Hello!

I need help scripting a gamepass vehicle spawner. Basically when a button is clicked the script checks to see if the user owns the gamepass if they own the gamepass it comes back true and spawns the vehicle. If it comes back false it prompts them to purchase the gamepass if they click cancel it simply doesn't spawn the vehicle.

I have attempted at scripting this already but it went horribly wrong! (i'm new to LUA xD)

Thank you to whoever helps out! :D

Here is the code i tried (doesn't work)

local passid = 9616452
local model = game.ServerStorage.SF2
debounce = false
local marketplaceservice = game:GetService("MarketplaceService")
function clicked(plr)   
    warn(plr.Name)


    if marketplaceservice:PlayerOwnsAsset(plr, passid) then
    if debounce == false then  
    debounce = true

    newModel = model:Clone()
    newModel.Parent = workspace 
    script.Parent.BrickColor = BrickColor.new("Bright red") 
    newModel:makeJoints() 
    wait(10)
    script.Parent.BrickColor = BrickColor.new("Navy blue") 

    debounce = false


    end

    else
        warn("User doesnt Own Pass Prompting a Purcahse")
        marketplaceservice:PromptPurchase(plr, passid, true)
    end



end


script.Parent.ClickDetector.MouseClick:Connect(clicked)
0
Try using UserOwnsGamePassAsync instead of PlayerOwnsAsset. AntiWorldliness 868 — 4y
0
Doesn't seem to work either. Until i can get it working i just have a basic invisible brick covering the whole area that teleports people away if they don't own the pass aswell as a gamepass ownership script in the vehicle seat RLX_Dev -5 — 4y

Answer this question