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

Why if someone dies do they lose their gun?

Asked by 10 years ago
game.Workspace.Guns.Changed:connect(function(t)
    print("Value Changed")
    if t == "Start" then
        print("Value = Start")
        local Player = game:GetService("Players").LocalPlayer
        local Item = game:GetService("ReplicatedStorage").Pistol:Clone()
        print("Player defined, item cloned")
        Item.Parent = Player.Backpack
        print("Item parented")
    end
end)

This is in a LocalScript and in StarterGui. I neeed it to give the player and gun and if they die and respawn to still give them the gun. After the round has ender, I have a script which removes the gun from the players inventory.

0
Why not add it to Starter Pack and then when the round ends remove it from starter pack? VariadicFunction 335 — 10y
0
no cause then they spawn with it at the start. I have it so they dont start then they get one they they lose it again NinjoOnline 1146 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago
game.Workspace.Guns.Changed:connect(function(t)
    print("Value Changed")
    if t == "Start" then
        print("Value = Start")
        local Player = game:GetService("Players").LocalPlayer
        local Item = game:GetService("ReplicatedStorage").Pistol:Clone()
        print("Player defined, item cloned")
        Item.Parent = Player.Backpack
        print("Item parented")

        Player.CharacterAdded:connect(function()
                local Item = game:GetService("ReplicatedStorage").Pistol:Clone()
                print("Item cloned")
                Item.Parent = Player.Backpack
                print("Item parented")
        end)
    end
end)

Perhaps this will work, un-tested.

NOTE: If it doesn't work don't just straight out down-vote the post, explain what happens and give output if possible

0
wont that just add the gun to the players starter pack the second they join? NinjoOnline 1146 — 10y
0
uh try it, I don't believe so... VariadicFunction 335 — 10y
Ad

Answer this question