Equipping tools in StarterGear

Cloning a sword into the player’s StarterGear but I want them to be able to use it aswell, how do I do this?

game.Players.PlayerAdded:Connect(function(Player)
	local Character = Player.CharacterAdded:Wait()
	local HasPass = false
	
	local Success, ErrorMessage = pcall(function()
		HasPass = MS:UserOwnsGamePassAsync(Player.UserId, GamepassID)
	end)
	
	if HasPass then
		local C_Sword = Sword:Clone()
		C_Sword.Parent = Character
	end
end)

This is all I have right now and I have absolutely no idea how to put the sword in the backpack and startergear so they don’t loose it when they die.

This code will grant them the sword and should automatically re-grant it on respawn.

game.Players.PlayerAdded:Connect(function(Player)
	local Character = Player.CharacterAdded:Wait()
	local HasPass = false

	pcall(function()
		HasPass = MS:UserOwnsGamePassAsync(Player.UserId, GamepassID)
	end)

	if HasPass then
		local C_Sword = Sword:Clone()
		C_Sword.Parent = Character

		C_Sword = Sword:Clone()
		C_Sword.Parent = Player.StarterGear
	end
end)
1 Like

Okay that works, but it doesn’t work for this block:

MS.PromptGamePassPurchaseFinished:Connect(function(Player, ID, Purchased)
	local Character = Player.CharacterAdded:Wait()
	
	if Purchased and ID == GamepassID then
		local C_Sword = Sword:Clone()
		C_Sword.Parent = Character
	end
end)
MS.PromptGamePassPurchaseFinished:Connect(function(Player, ID, Purchased)
	local Character = Player.CharacterAdded:Wait()
	
	if Purchased and ID == GamepassID then
		local C_Sword = Sword:Clone()
		C_Sword.Parent = Character

        C_Sword = Sword:Clone()
		C_Sword.Parent = Player.StarterGear
	end
end)

Why does this one use a local variable?

oops, forgot to remove. I just copy pasted the original csword line

So it would work without using local, correct?

1 Like

If I have to be honest, I have no idea why this actually works. Could you explain it a little?

As well as cloning the sword to the character, it clones it to the players StarterGear folder. When a players character spawns the contents of the folder is copied to the character.

1 Like