Hello, I’ve tried to make a gamepass but my script doesn’t work and I don’t understand why, so I’ve tried to print the bool value to know if a player has bought the gamepass and it’s work perfectly until the character die :
ServerScriptService :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local RemoteEvent = ReplicatedStorage.GamePass
local Players = game:GetService("Players")
local GamePass = 100274949
Players.PlayerAdded:Connect(function(Player)
local HasBoughtGamePass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePass)
if HasBoughtGamePass then
RemoteEvent:FireClient(Player)
end
end)
StarterCharacterScript :
local UserInputService = game:GetService("UserInputService")
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.GamePass
local Players = game.Players
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local GamePass = 100274949
local CanDoubleJump = false
local HasDoubleJumped = false
local HasBoughtGamePass = false
RemoteEvent.OnClientEvent:Connect(function()
HasBoughtGamePass = true
end)
MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player, BoughtGamePass, Purchased)
if BoughtGamePass == GamePass and Purchased then
HasBoughtGamePass = true
end
end)
Humanoid.StateChanged:Connect(function(Old, New)
if Old == Enum.HumanoidStateType.Jumping and New == Enum.HumanoidStateType.Freefall then
CanDoubleJump = true
else
CanDoubleJump = false
end
end)
Humanoid.StateChanged:Connect(function(Old, New)
if Old == Enum.HumanoidStateType.Freefall and New == Enum.HumanoidStateType.Landed then
HasDoubleJumped = false
end
end)
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
if CanDoubleJump and not HasDoubleJumped and HasBoughtGamePass then
HasDoubleJumped = true
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end)