I am making armor and this script says that it is putting armor on the player when they join but I cannot see it there! Help!

game.Players.PlayerAdded:Connect(function(Player)
	local Chestplate = Database:GetAsync(Player.UserId.."CHESTPLATE") or false
	Player.CharacterAdded:Connect(function(Char)
		if Chestplate then
			print(Chestplate)
			local Torso = nil 
			if Char.Humanoid.RigType == Enum.HumanoidRigType.R15 then
				Torso = Char:WaitForChild('UpperTorso')
			else
				Torso = Char:WaitForChild('Torso')
			end
			local BodyItem = script[Chestplate]:Clone()
			print(BodyItem)
			BodyItem.Weld.Part1 = Torso
			BodyItem.Weld.C0 = CFrame.new(-0.022, 0, 0)*CFrame.fromEulerAnglesXYZ(-math.pi/2, math.pi/2,-math.pi)
			BodyItem.Parent = Char:WaitForChild("Armor")
		end
	end)
end)

2 comments

0

Loading data shouldn't be done like that. You also try indexing using what you get from the DataStore so I assume you either load a string or bool value. This won't work when the condition in line 2 goes to "false". Recommend you not attempt DataStores until you fix the rest.

0

@xPolarium the database works. That is not the problem. It is mysteriously not putting it on me even though it prints what it is supposed to