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

My gamepass button that also works as a normal button isn't working?

Asked by 6 years ago

Here is the client script

LocalPlayer = game.Players.LocalPlayer
Character = LocalPlayer.Character
ButtonPressed = false

script.Parent.Activated:Connect(function()
    if ButtonPressed == false then
        if game.MarketplaceService:PlayerOwnsAsset(LocalPlayer, 5010729) then

            ButtonPressed = true
            script.Parent.Text = ("Stop Torque")
            game.ReplicatedStorage.RemoteGamepassTorque:FireServer(Character, true)

        else

            game.MarketplaceService:PromptGamePassPurchase(LocalPlayer, 5010729)

        end
    else
        if game.MarketplaceService:PlayerOwnsAsset(LocalPlayer, 5010729) then

            ButtonPressed = false
            script.Parent.Text = ("Start Torque")
            game.ReplicatedStorage.RemoteGamepassTorque:FireServer(Character, false)

        else

            game.MarketplaceService:PromptGamePassPurchase(LocalPlayer, 5010729)

        end
    end
end)

Here is the server script.

game.ReplicatedStorage.RemoteGamepassTorque.OnServerEvent:Connect(function(Player, Character, Value)
    if Value == true then

        Torque.Torque = Vector3.new(100000,100000,100000)
        Torque.Attachment0 = Character.Head.HatAttachment
        Torque.Parent = Character.Head

    else

        GamepassTorque.Parent = nil

    end
end)
0
Just a guess, but I don't think the client can access marketplaceservice. Try moving all of the if statements to the server script. Abandion 118 — 6y
0
@ above is correct green271 635 — 6y
0
I'll try that! PoweredBy_Memes 2 — 6y
0
Actually the MarketplaceService CAN be accessed from the client. If you're checking for a game pass though, use UserOwnsGamePassAsync,and use from server and instead of the player it's their UserId User#19524 175 — 6y

Answer this question