Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why if someone dies do they lose their gun?

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.

2 comments

0

Why not add it to Starter Pack and then when the round ends remove it from starter pack?

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

1 answer

✓ Accepted answer
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

2 comments

0

wont that just add the gun to the players starter pack the second they join?

0

uh try it, I don't believe so...

This discussion is preserved as it was. New answers, comments, and votes are closed.