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

Script not giving player the gear, no error? Please help

Im fairly new to scripting; messy code that i came up in my head because im too small brain to think of a simpler way

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			local Player = game.Players.LocalPlayer
			local number = math.random(1,4)
			if number == 1 then
				wait(6)
				print(1)
				local gear = workspace.Folder.ClassicSword:Clone()
				gear.Parent = Player
			elseif number == 2 then
				wait(6)
				print(2)
				local gear = workspace.Folder.RedHyperLaser:Clone()
				gear.Parent = Player
			elseif number == 3 then
				wait(6)
				print(3)
				local gear = workspace.Folder.HyperlaserGun:Clone()
				gear.Parent = Player
			elseif number == 4 then
				wait(6)
				print(4)
				local gear = workspace.Folder.Epicsword:Clone()
				gear.Parent = Player
			end
		end)
	end)
end)



1 answer

✓ Accepted answer

You don't put a tool in the actual Player, theres a Backpack child for all of the players, or you can parent it to the character, which will automatically equip it.

gear.Parent = Player.Backpack

7 comments

0

thanks

0

thanks

0

wait it says attempt to index nil with backpack (i moved folder to serverstorage and changed code so its in server storage and its a script)

1

local player does not exist on server, you already have variable for player on line 1, just remove line 5 and change all references of Player to player

0

ohhhh ok

0

ohhhh ok

0

thanks to both of you

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