I wanted to make a shop, that if I click on buy, it will sent the player into the buying screen and when its bought, he is walking faster, but when he respawns, he loses his faster walk. Please help me!
local Marketplace = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
Marketplace:PromptGamePassPurchase(Player, 9586786)
end)
Marketplace.PromptGamePassPurchaseFinished:Connect(function(purchased)
if purchased then
Player.Character.Humanoid.WalkSpeed = 40
end
end)
game.Players.PlayerAdded:Connect(function(plr)
if Marketplace:UserOwnsGamePassAsync(Player.UserID, 9586786) then
Player.Character.Humanoid.WalkSpeed = 40
end
end)
game.Players.PlayerAdded:Connect(function(plr)
if Marketplace:UserOwnsGamePassAsync(Player.UserID, 9586786) then
Player.Character.Humanoid.WalkSpeed = 40
end
end)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
if Marketplace:UserOwnsGamePassAsync(Player.UserID, 9586786) then
Playerz.Character.Humanoid.WalkSpeed = 40
end
end)
end

5 comments
what is "Playerz"
i forgot to change playerz to player
but that is not the cause of the problem.
try useing this script to check if the player owns the gamepass
local MarketPlaceService = game:GetService"MarketPlaceService" local function ownsgamepass(userid,gamepassid) local s,res = pcall(MarketPlaceService.UserOwnsGamePassAsync,MarketPlaceService,userid,gamepassid) if not s then res = false end return res end