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)
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)
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.