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

why my gamepass's tool dispears when I respawn my character ?

Asked by 5 years ago

Hello everyone, so I don't understand why my gamepass's tool dispears when I respawn my character. When I join my game, my tool appears but when I die, nothing. Why ? My script in ServerScriptService:

01local Gid = 7835473
02local mps = game:GetService("MarketplaceService")
03print(12)
04 
05game.Players.PlayerAdded:Connect(function(player)
06    print(1)
07    if mps:UserOwnsGamePassAsync(player.UserId, Gid) then
08        print(2)
09        game.ServerStorage.AdminCard:Clone().Parent = player:WaitForChild("Backpack")
10 
11 
12 
13    end
14end)
15 
16game.ReplicatedStorage.Give.OnServerEvent:Connect(function(player)
17    print(3)
18    game.ServerStorage.AdminCard:Clone().Parent = player:WaitForChild("Backpack")
19end)

My another script in my GUI:

01local mps = game:GetService("MarketplaceService")
02local id = 7835473
03 
04script.Parent.MouseButton1Click:Connect(function()
05    local player = game.Players.LocalPlayer
06    mps:PromptGamePassPurchase(player, id)
07end)
08 
09mps.PromptGamePassPurchaseFinished:Connect(function(player, idG, purchased)
10    if idG == id and purchased then
11        game.ReplicatedStorage.Give:FireServer()
12    end
13end)

Thank you in advance !

0
You have to put it on StarterGear if its a object. And if you want to save it, you need to know how to use DataStore. Let me know if you want a script explaining you how to do it. c: Foxy_Developer 111 — 5y

1 answer

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

Ok... Lets try it!

First Step : First of all we need to know what is the "Market Place" service on Roblox API so we can get the Gamepass.

Link : [https://developer.roblox.com/en-us/api-reference/class/MarketplaceService]

Second Step : Second, we need to know how to access to a player that owns the Gamepass, but first we need the ID of the Gamepass. [You can get it by going to your gamepass page and looking for the URL, then you will see some numbers. That's the ID of your gamepass.]

1--> The locals <--
2 
3local iD = 7835473
4local mP = game:GetService("MarketplaceService")

That's how we acces to the Service and store the ID on a variable! So lets now fix your code!

Third Step : Enjoy coding! You always have to enjoy what are you doing! Play some music while you script or even play a game before to relax yourself.

Lets get into code

01--> Locals <--
02 
03local id = 7835473
04local marketplace = game:GetService("MarketplaceService")
05local RS = game:GetService("ReplicatedStorage")
06local tool = RS:WaitForChild("Tool") --> Change it to your tool name
07 
08--> Code <--
09 
10game.Players.PlayerAdded:Connect(function(player)
11    if mp:UserOwnsGamePassAsync(player.UserId,Gid) then
12    print("We are ok")
13 
14    local clone1 = tool:Clone()
15    local clone2 = tool:Clone()
View all 25 lines...

That's how you fix it easealy. There's a bug so before you can't acces to the StarterGear like normaly we did it. So now is kinda fixed.

I hope my answer already solved your question. If its like that, please accept my answer. So you can let me know this helps you!

Note : The edit are for grammatical errors.

Keep scripting!

0
I thought StarterGear was deprecated St_vnC 330 — 5y
0
Yeah, but now you can acces to the StaterGear with a WaitForChild function Foxy_Developer 111 — 5y
Ad

Answer this question