Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

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

Asked by 3 months 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 — 3mo

1 answer

Log in to vote
1
Answered by 3 months 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