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

how do i make it so that people dont loose there item?

Asked by 3 years ago

this works in the way that the player gets the item and when he/she resets/dies they will get it in there inventory and what doesn't work is that other players when they die the item stays in server storage and its a problem when it leaves the inventory, in general, how would I fix this thank you

local gamepassid_ = 10022825
local b = game:GetService("ServerStorage"):FindFirstChild("GravityCoil"):Clone()


game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 10022825) then
        if player.Backpack:FindFirstChild("GravityCoil") == nil then
            game.ServerStorage:FindFirstChild("GravityCoil"):Clone()
            b.Parent = player.Backpack 
        end
    end
end)


    game:GetService('Players').PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(character)
            character:WaitForChild("Humanoid").Died:Connect(function()
    b:clone()
    game:GetService("ServerStorage"):FindFirstChild("Gravitycoil"):clone()
    wait(5.2)
    print(gamepassid_)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 10022825) then
        if player.Backpack:FindFirstChild("GravityCoil") == nil then
            game.ServerStorage:FindFirstChild("GravityCoil"):Clone()
            b.Parent = player.Backpack 
        end
    end
end)

            end)
        end)
0
remove the .Died inside characteradded Subsz 366 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

Players have a .StarterGear which holds items that they spawn with. So you could do;

local gamepassid_ = 10022825
local b = game:GetService("ServerStorage"):FindFirstChild("GravityCoil"):Clone()


game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 10022825) then
        if player.Backpack:FindFirstChild("GravityCoil") == nil then
            game.ServerStorage:FindFirstChild("GravityCoil"):Clone().Parent = player.StarterGear --Adds it to their startergear
            b.Parent = player.Backpack 
        end
    end
end)
Ad

Answer this question