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

Why won't my script move gear out of the server storage and into a person's backpack?

I have been working on this script for a while now, and I have asked multiple questions on this site about but I haven't really gone anywhere. Every time I solve a problem, a new one pops up. When you join, it doesn't give you any gear, even though it is supposed to give you gear based on the level. Before, I only gave portions of the script, but this time I will include the entire thing. This is the 17th version of this script, and I am starting to get frustrated. I am a beginner scripter, and I really need help with this. Thank you, Legobrain9275

wait(5)
game.Players.PlayerAdded:connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local level = leaderstats:WaitForChild("Level")
local stats = level.Value

local lev0 = false
local lev1 = false
local lev2 = false
local lev3 = false
local lev4 = false
local lev5 = false
local lev6 = false
local lev7 = false
local lev8 = false
local lev9 = false
local lev10 = false

	while true do

		if stats >= 0 and lev0 == false then
			local flashlight = game.ServerStorage.Flashlight:Clone()
			flashlight.Parent = player.Backpack
			flashlight.Parent = player.StarterGear
			lev0 = true
		end
		if stats >= 1 and lev1 == false then
			local gravcoil = game.ServerStorage.GravityCoil_Level1:Clone()
			gravcoil.Parent = player.Backpack
			gravcoil.Parent = player.StarterGear
			lev1 = true

		end
		if stats >= 2 and lev2 == false then
			local icestaff = game.ServerStorage.IceStaff_Level1:Clone()
			icestaff.Parent = player.Backpack
			icestaff.Parent = player.StarterGear
			lev2 = true

		end
		if stats >= 3 and lev3 == false then
			local laser = game.ServerStorage.Laser:Clone()
			laser.Parent = player.Backpack
			laser.Parent = player.StarterGear
			lev3 = true

		end
		if stats >= 4 and lev4 == false then
			local bomb = game.ServerStorage.Timebomb_Level1:Clone()
			bomb.Parent = player.Backpack
			bomb.Parent = player.StarterGear
			lev4 = true

		end
		if stats >= 5 and lev5 == false then
			local rwand = game.ServerStorage["Rust Wand"]:Clone()
			rwand.Parent = player.Backpack
			rwand.Parent = player.StarterGear
			lev5 = true

		end
		if stats >= 6 and lev6 == false then
			local firef = game.ServerStorage.Fireflies:Clone()
			firef.Parent = player.Backpack
			firef.Parent = player.StarterGear
			lev6 = true

		end
		if stats >= 7 and lev7 == false then
			local grav2 = game.ServerStorage.GravityCoil_Level2:Clone()
			grav2.Parent = player.Backpack
			grav2.Parent = player.StarterGear
			player.Backpack.GravityCoil_Level1:Destroy()
			player.StarterGear.GravityCoil_Level1:Destroy()
			lev7 = true

		end
		if stats >= 8 and lev8 == false then
			local i2 = game.ServerStorage.IceStaff_Level2:Clone()
			i2.Parent = player.Backpack
			i2.Parent = player.StarterGear
			player.Backpack.IceStaff_Level1:Destroy()
			player.StarterGear.IceStaff_Level1:Destroy()
			lev8 = true
		end				
		wait(1)	
	end
end)

1 answer

✓ Accepted answer

It seems you are putting it in backpack, but then moving it to StarterGear. If it is in startergear, then you need to die before you obtain it. If you want to keep it in Backpack, simply remove the part that says "flashlight.Parent = player.StarterGear." If you want to put it in their backpack, and have them keep it when they die without killing them, do this:

if stats >= 0 and lev0 == false then
	local flashlight = game.ServerStorage.Flashlight:Clone()
	local flashlight2 = game.ServerStorage.Flashlight:Clone()
	flashlight.Parent = player.Backpack
	flashlight2.Parent = player.StarterGear
	lev0 = true

Hope this helps :)

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