WHOEVER HELPS ME FIX THIS GETS SOLUTION 100% GUARENTEED! this is urgent that i fix this
I’m making a double jump gamepass that has a button you can press to toggle it on or off. I have the double jump system done so if I were to just use that double jump system then everyone could use it. But I want to make a button that detects if the player has the gamepass by using
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 123)
if they have the gamepass then the double jump is toggled on
heres what i have so far
local MarketplaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
local Button = script.Parent
local RemoteEvent = game.ReplicatedStorage.ActivateDoubleJump
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 185857200) then
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
script.Parent.Text = 'ENABLE DOUBLE JUMP'
else
script.Parent.BackgroundColor3 = Color3.fromRGB(0, 166, 255)
script.Parent.Text = 'BUY DOUBLE JUMP'
end
Button.MouseButton1Click:Connect(function()
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 185857200) then
RemoteEvent:FireServer()
else
MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, 185857200)
end
end)
RemoteEvent.OnClientEvent:Connect(function(DoubleJumpState)
if DoubleJumpState == true then
script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
script.Parent.Text = 'DOUBLE JUMP: ON'
else
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
script.Parent.Text = 'DOUBLE JUMP: OFF'
end
end)
and i have a serverscript thats in serverscriptservice
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local DoubleJumpLocal = game.StarterPlayer.StarterCharacterScripts.DoubleJumpLocal
DoubleJumpLocal.Enabled = false
local PlayersWithDoubleJump = {} -- Table Containing People With Double Jump Enabled
-- Table Check
local function checkTableForValue(t, value)
for i, v in pairs(t) do
if v == value then
return i
end
end
return false
end
-- Double Jump Handler
game.ReplicatedStorage['ActivateDoubleJump'].OnServerEvent:Connect(function(p)
if MarketplaceService:UserOwnsGamePassAsync(p.UserId, 185857200) then
if checkTableForValue(PlayersWithDoubleJump, p) ~= false then
table.remove(PlayersWithDoubleJump, checkTableForValue(PlayersWithDoubleJump, p))
DoubleJumpLocal.Enabled = false
else
table.insert(PlayersWithDoubleJump, p)
DoubleJumpLocal.Enabled = true
end
end
end)
how do i make a button that enables and disables the double jump if they have a gamepass