Hello there,
I've tried in multiple different ways to do the same thing. It just won't work, is there some obvious mistake I've just missed? I'm simply trying to make a function that when a user dies (or if chosen with a server event) load the users inventory. When loading the users inventory it would then check if and what gamepasses the user has. If the user has VIP, then it should not check for the other passes, but if not it should. I'm stuck.
Current Code
local mps = game:GetService("MarketplaceService")
local supercoil = game.ReplicatedStorage.SuperCoil
local supercoilid = 5892398
local HasSuperCoil = false
local grapplehook = game.ReplicatedStorage.GrappleHook
local grapplehookid = 5892399
local HasGrappleHook = false
local gravitycoil = game.ReplicatedStorage.GravityCoil
local gravitycoilid = 5892400
local HasGravityCoil = false
local speedcoil = game.ReplicatedStorage.SpeedCoil
local speedcoilid = 5892401
local HasSpeedCoil = false
local VIP = 5892397
--- Check if and what gamepasses user has.
function CheckVIP()
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if mps:UserOwnsGamePassAsync(player.UserId,VIP) then
print(player.Name .. " has the VIP gamepass!")
local clone = game.ReplicatedStorage.GrappleHook:Clone()
clone.Parent = player:WaitForChild("Backpack")
local clone = game.ReplicatedStorage.SuperCoil:Clone()
clone.Parent = player:WaitForChild("Backpack")
local clone = game.ReplicatedStorage.GravityCoil:Clone()
clone.Parent = player:WaitForChild("Backpack")
local clone = game.ReplicatedStorage.SpeedCoil:Clone()
clone.Parent = player:WaitForChild("Backpack")
else
print(player.Name .. " does not have the VIP gamepass...")
end
end)
end)
end
function CheckGrappleHook()
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if mps:UserOwnsGamePassAsync(player.UserId,grapplehookid) then
print(player.Name .. " has the grapple hook gamepass!")
local clone = game.ReplicatedStorage.GrappleHook:Clone()
clone.Parent = player:WaitForChild("Backpack")
else
print(player.Name .. " does not have the grapple hook gamepass...")
end
end)
end)
end
function CheckSuperCoil()
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if mps:UserOwnsGamePassAsync(player.UserId,supercoilid) then
print(player.Name .. " has the Super Coil gamepass!")
local clone = game.ReplicatedStorage.SuperCoil:Clone()
clone.Parent = player:WaitForChild("Backpack")
else
print(player.Name .. " does not have the Super Coil gamepass...")
end
end)
end)
end
function CheckSpeedCoil()
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if mps:UserOwnsGamePassAsync(player.UserId,speedcoilid) then
print(player.Name .. " has the Speed Coil gamepass!")
local clone = game.ReplicatedStorage.SpeedCoil:Clone()
clone.Parent = player:WaitForChild("Backpack")
else
print(player.Name .. " does not have the Speed Coil gamepass...")
end
end)
end)
end
function CheckGravityCoil()
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if mps:UserOwnsGamePassAsync(player.UserId,gravitycoilid) then
print(player.Name .. " has the Gravity Coil gamepass!")
local clone = game.ReplicatedStorage.GravityCoil:Clone()
clone.Parent = player:WaitForChild("Backpack")
else
print(player.Name .. " does not have the Gravity Coil gamepass...")
end
end)
end)
end
function LoadInventory()
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
player:WaitForChild("Backpack")
if mps:UserOwnsGamePassAsync(player.UserId,5892397) then
print("The script won't go further than here.")
CheckVIP()
else
CheckGrappleHook()
CheckSuperCoil()
CheckSpeedCoil()
CheckGravityCoil()
end
end)
end)
end
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
LoadInventory()
print(player.Name .. "'s inventory has been loaded.")
end)
end)
LoadInventory()

1 comment
Thank you very much for the help! You spent a lot of time explaining this and I am very thankful!