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

Trying to make it continue the script or skip 10 seconds if play has GP, help?

Asked by 6 years ago

Errors: None

local SkipAnimID = 944401378
game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, SkipAnimID) then
    print("Worked")
    else
        wait(10)
    end
end)

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

The function PlayerOwnsAsset no longer works with game passes or badges so you now must use the corresponding service to check this kind of data.

All you need to do is change this script to use the function PlayerHasPass which is only accessible on the server side.

Example, serser script:-

local gamePassServ = game:GetService('GamePassService')

game.Players.PlayerAdded:connect(function(plr)
    if gamePassServ:PlayerHasPass(plr, 944401378) then
        -- You may also need a remote event to let the player know they have the gamepass
    else
        wait(10)    -- ??
    end
end)

I hope this helps.

Ad
Log in to vote
0
Answered by
deris88 146
6 years ago
Edited 6 years ago

Hi.

If this is a server script located inside of a GUI and FE is enabled, the script will not work. If this is local script, it will not work.

However you can make it work using a Server script and a remote event.

Here is an example:

--SERVER SCRIPT inside of ServerScriptService

local Event = Instance.new("RemoteEvent")
Event.Parent = game:WaitForChild("ReplicatedStorage")
Event.Name = "SkipAnim"

local SkipAnimID = 944401378
game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, SkipAnimID) then
        Event:FireClient(player)
    else
        wait(10)
    end
end)

--LOCAL SCRIPT inside of GUI

game:WaitForChild("ReplicatedStorage").
local Event = game.ReplicatedStorage:FindFirstChild("SkipAnim")

Event.OnClientEvent:connect(function(player)
    print ("Player has pass")
    --The rest of code goes here
end)

Hope this helps!

Answer this question